PHP v8.2.5
I have a couple of products within a category that are priced per hour, adding a '/hr' suffix to the price when using DPU is beyond me so I am adding the price/hour as a text field near the $products_name using this code
PHP Code:
<?php
if (($_GET['products_id'] == '631') || ($_GET['products_id'] == '633')) {
echo '<span class="priceHour">' . VOUCHER_PER_HOUR_PRE . zen_get_products_display_price((int)$_GET['products_id']) . VOUCHER_PER_HOUR_POST . '</span>';
}
?>
this displays as
(£45.00/hr)
I would like it do display to zero decimal places, but using this code
PHP Code:
<?php
if (($_GET['products_id'] == '631') || ($_GET['products_id'] == '633')) {
echo '<span class="priceHour">' . VOUCHER_PER_HOUR_PRE . round(zen_get_products_display_price((int)$_GET['products_id']), 0) . VOUCHER_PER_HOUR_POST . '</span>';
}
?>
gives a fatal error
Code:
[17-Sep-2023 14:12:46 Europe/London] PHP Fatal error: Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, string given in D:\wamp64\www\mydomain.co.uk\includes\templates\my_template\templates\tpl_product_info_display.php:86
how should I correctly structure the 'round' code to display as
(£45/hr)
Bookmarks