From d68ef09e06caebfd75c4eb53cc9da84a6fd0de37 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 27 Jul 2012 15:11:09 +0100 Subject: [PATCH] Round the discount. Closes #1297. With cart percent discounts, before tax, we do it per item to account for varying tax rates. We need to round these values so the totals match. This may result in a 1p more or less overall, but per item it is correct. --- classes/class-wc-cart.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/class-wc-cart.php b/classes/class-wc-cart.php index f185a8bf840..03d82ec4af3 100644 --- a/classes/class-wc-cart.php +++ b/classes/class-wc-cart.php @@ -932,9 +932,10 @@ class WC_Cart { case "percent" : - $percent_discount = ( $values['data']->get_price( ) / 100 ) * $coupon->amount; + $percent_discount = round( ( $values['data']->get_price() / 100 ) * $coupon->amount, 2 ); - if ( $add_totals ) $this->discount_cart = $this->discount_cart + ( $percent_discount * $values['quantity'] ); + if ( $add_totals ) + $this->discount_cart = $this->discount_cart + ( $percent_discount * $values['quantity'] ); $price = $price - $percent_discount;