Skip to content

Commit

Permalink
Merge pull request #443 from Billmate/WPM-132
Browse files Browse the repository at this point in the history
WPM-132 [BUGFIX] Updated shipping tax calculations to fix incorrect n…
  • Loading branch information
MattiasNilsson authored Apr 20, 2020
2 parents 7067578 + 2d2eb63 commit 6d77f27
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/commonfunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
Expand Down

0 comments on commit 6d77f27

Please sign in to comment.