Skip to content

Commit

Permalink
Merge branch 'master' of github.com:vyskoczilova/woocommerce-payforpa…
Browse files Browse the repository at this point in the history
…yment
  • Loading branch information
vyskoczilova committed Sep 16, 2021
2 parents 89bfba5 + fbe8145 commit 69b8090
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Unreleased updates
------------------

* Fix - WPML exchange rates (apply filter `wcml_raw_price_amount`)
* Fix - tax class when taxes by cart items is on - applies the highest used tax. Thanks to [morvy](https://github.com/morvy)

## Credits

Expand Down
19 changes: 19 additions & 0 deletions inc/class-pay4pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,25 @@ public function calculate_pay4payment() {
// WooCommerce Fee is always ex taxes. We need to subtract taxes, WC will add them again later.
if ( $taxable && $include_taxes ) {

// Apply the highest tax in the cart (see #65)
if ( $tax_class === 'inherit' ) {
$highestTaxRate = 0;
if ( $cart->get_cart() ) {
foreach ( $cart->get_cart() as $item ) {
if ( !$item['line_tax'] || !$item['line_total'] ) {
$itemTaxRate = 0;
} else {
$itemTaxRate = $item['line_tax'] / $item['line_total'];
}

if ( $itemTaxRate >= $highestTaxRate ) {
$highestTaxRate = $itemTaxRate;
$tax_class = $item['data']->tax_class;
}
}
}
}

$tax_rates = WC_Tax::get_rates( $tax_class );

$factor = 1;
Expand Down

0 comments on commit 69b8090

Please sign in to comment.