Taxes should be rounded on subtotals in cart when option woocommerce_tax_round_at_subtotal is checked.

This commit is contained in:
Grzegorz Rola 2018-08-29 13:22:51 +02:00
parent b80c6d86fc
commit dafcbc56b0
1 changed files with 19 additions and 0 deletions

View File

@ -580,9 +580,28 @@ final class WC_Cart_Totals {
} }
} }
$taxes = $this->round_merged_taxes( $taxes );
return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes ); return $in_cents ? $taxes : wc_remove_number_precision_deep( $taxes );
} }
/**
* Round merged taxes.
*
* @since 3.4.5
* @param array $taxes Taxes to round.
* @return array
*/
protected function round_merged_taxes( $taxes ) {
if ( $this->round_at_subtotal() ) {
foreach ( $taxes as $rate_id => $tax ) {
$taxes[ $rate_id ] = wc_round_tax_total( $tax, 0 );
}
}
return $taxes;
}
/** /**
* Combine item taxes into a single array, preserving keys. * Combine item taxes into a single array, preserving keys.
* *