diff --git a/inc/utils.php b/inc/utils.php index 984e54f3..6a183ffd 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -186,7 +186,11 @@ function mollieWooCommerceFormatCurrencyValue($value, $currency) if (in_array($currency, $currenciesWithNoDecimals)) { return number_format($value, 0, '.', ''); } - + // trying to avoid floating point issues + $value = $value * 1000; + $value = (int) $value / 1000; //drop the last decimal after the third + $value = round($value, 3); + $value = round($value, 2, PHP_ROUND_HALF_DOWN); //round down, as seems woo like it :) return number_format($value, 2, '.', ''); } diff --git a/src/Payment/OrderLines.php b/src/Payment/OrderLines.php index 440bda15..de67b7c5 100644 --- a/src/Payment/OrderLines.php +++ b/src/Payment/OrderLines.php @@ -560,7 +560,7 @@ private function get_shipping_vat_rate() { $shipping_vat_rate = 0; if (WC()->cart->shipping_tax_total > 0) { - $shipping_vat_rate = round(WC()->cart->shipping_tax_total / WC()->cart->shipping_total, 2) * 100; + $shipping_vat_rate = round(WC()->cart->shipping_tax_total / WC()->cart->shipping_total, 4) * 100; } return $shipping_vat_rate;