Hello, I need to round the price before it gets displayed. The issue is I cant create an addon to override fn_format_price function in the fn.common.php file. It worked when I directly edit the function in the file, but I don't wanna edit core files. What's the solution?
I tried creating an addon and install it but didn't work
function fn_my_changes_format_price_pre(&$price, $currency) {
// if you want currency dependent
if( $currency == 'usd' ) {
// do whatever
}
// to round up
$price = ceil($price);
// to round down
$price = floor($price);
// Or you can do custom rounding here.
$price = my_custom_price_adjustment($price, $currency);
}
I had to do this for a Dutch customer given they don't have 'pennies' so needed to round to appropriate 'nickle'.
one more thing, I have two currencies, when I need to round my currency, the $currency value in the format_price_pre function is showing a blank value ' '.
why is that?
Now we only have two currencies, and I'm rounding the secondary currency. But later if we had more currencies, I wanna round only one of them. How can I get which currency is being passed to the format_price_pre function?
Now we only have two currencies, and I'm rounding the secondary currency. But later if we had more currencies, I wanna round only one of them. How can I get which currency is being passed to the format_price_pre function?
Try the following condition
if ($currency == CART_PRIMARY_CURRENCY) {
...code for primary currency only....
}
Ecom, that won't work for the condition where the $currency value is empty (which it many times is). Hence the conditional statement would need to be something akin to:
Ecom, that won't work for the condition where the $currency value is empty (which it many times is). Hence the conditional statement would need to be something akin to: