From 2d2eb63b7086b6c3747d2ccf60317aa7865a0158 Mon Sep 17 00:00:00 2001 From: henrik-ecomatic Date: Thu, 16 Apr 2020 14:53:22 +0200 Subject: [PATCH] WPM-132 [BUGFIX] Updated shipping tax calculations to fix incorrect numbers on checkout --- src/commonfunctions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commonfunctions.php b/src/commonfunctions.php index 922c2de8..303ceda6 100644 --- a/src/commonfunctions.php +++ b/src/commonfunctions.php @@ -1882,11 +1882,11 @@ public function getCartShipping() { $shipping_tax = $cart_shipping_tax; } - if ($order_shipping_tax > 0 AND is_object(WC()->cart) == true AND method_exists(WC()->cart, 'get_cart_item_tax_classes') == true) { + if (is_object(WC()->cart) == true AND method_exists(WC()->cart, 'get_cart_item_tax_classes') == true) { // Get shipping tax rate from cart $rates = current(WC_Tax::get_shipping_tax_rates()); if (is_array($rates) AND isset($rates['rate'])) { - $taxzrate = round($rates['rate']); + $taxrate = round($rates['rate']); } } } else { @@ -1907,6 +1907,9 @@ public function getCartShipping() { $taxrate = ($shipping_tax / $shipping_total) * 100; } } + if ($shipping_tax == 0 && $taxrate > 0){ + $shipping_tax = $shipping_total*(1+($taxrate/100))-$shipping_total; + } return array( "price" => round($shipping_total * 100),