From 20ac4a8b69d5acd9af81b35982b52878fd738cd0 Mon Sep 17 00:00:00 2001 From: Grzegorz Rola Date: Wed, 29 Aug 2018 13:34:22 +0200 Subject: [PATCH] Taxes should be rounded on subtotals in cart when option woocommerce_tax_round_at_subtotal is checked. --- includes/class-wc-cart-totals.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/class-wc-cart-totals.php b/includes/class-wc-cart-totals.php index 538977363f0..34f64c1f396 100644 --- a/includes/class-wc-cart-totals.php +++ b/includes/class-wc-cart-totals.php @@ -579,10 +579,28 @@ final class WC_Cart_Totals { $taxes[ $rate_id ] += $this->round_line_tax( $rate ); } } + $taxes = $this->round_merged_taxes( $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. *