From 5f2bc29e3db05191ee0da8c3a0829d9fd46237dd Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 15 Jan 2019 10:17:31 -0400 Subject: [PATCH] include taxes in subtotal when coupon price includes taxes --- includes/class-wc-discounts.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-wc-discounts.php b/includes/class-wc-discounts.php index fea4eead963..c4e931f6d7f 100644 --- a/includes/class-wc-discounts.php +++ b/includes/class-wc-discounts.php @@ -664,6 +664,11 @@ class WC_Discounts { */ protected function validate_coupon_minimum_amount( $coupon ) { $subtotal = wc_remove_number_precision( $this->get_object_subtotal() ); + + if ( $this->object->get_prices_include_tax() ) { + $subtotal += round( $this->object->get_total_tax(), wc_get_price_decimals() ); + } + if ( $coupon->get_minimum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_minimum_amount', $coupon->get_minimum_amount() > $subtotal, $coupon, $subtotal ) ) { /* translators: %s: coupon minimum amount */ throw new Exception( sprintf( __( 'The minimum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_minimum_amount() ) ), 108 );