include taxes in subtotal when coupon price includes taxes

This commit is contained in:
Ron Rennick 2019-01-15 10:17:31 -04:00
parent 507f67cb38
commit 5f2bc29e3d
1 changed files with 5 additions and 0 deletions

View File

@ -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 );