Problems with function apply_rounding_rules()
-
Hello I’ve recently discovered problems with this function. Especially when you’re using it with convert_price_amount() like on line 832 in multi-currency class Problem is that you’ve passed price with commas and all special characters and then ceil() or floor() doesn’t work.
Here is a little function, for removing all characters except numbers and decimals dot. Feel free to use it.function float_number($num) { $dotPos = strrpos($num, '.'); $commaPos = strrpos($num, ','); $sep = (($dotPos > $commaPos) && $dotPos) ? $dotPos : ((($commaPos > $dotPos) && $commaPos) ? $commaPos : false); if (!$sep) { return floatval(preg_replace("/[^0-9]/", "", $num)); } return floatval( preg_replace("/[^0-9]/", "", substr($num, 0, $sep)) . '.' . preg_replace("/[^0-9]/", "", substr($num, $sep+1, strlen($num))) ); }
Hope this helps. Thank you.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problems with function apply_rounding_rules()’ is closed to new replies.