include taxes in subtotal when validating tax inclusive coupon maximum as well

This commit is contained in:
Ron Rennick 2019-01-15 10:33:57 -04:00
parent acf46fa28d
commit d654107cb0
1 changed files with 5 additions and 0 deletions

View File

@ -687,6 +687,11 @@ class WC_Discounts {
*/
protected function validate_coupon_maximum_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_maximum_amount() > 0 && apply_filters( 'woocommerce_coupon_validate_maximum_amount', $coupon->get_maximum_amount() < $subtotal, $coupon ) ) {
/* translators: %s: coupon maximum amount */
throw new Exception( sprintf( __( 'The maximum spend for this coupon is %s.', 'woocommerce' ), wc_price( $coupon->get_maximum_amount() ) ), 112 );