Fix for free shipping handling of minimum order rule (#39155)

Fixes the calculation from when Apply minimum order rule before coupon discount is active and prices are entered inclusive of tax and displayed that way in cart and checkout, free shipping is no longer available (based on the minimum order amount including tax), as it uses the pre-tax amount when a coupon is applied.

Fixes #28752
This commit is contained in:
Corey McKrill 2023-07-18 17:00:39 -07:00 committed by GitHub
commit 00073c0d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Ensure that the full discount is ignored in free shipping minimum order calculations when ignore_discount setting is enabled

View File

@ -162,12 +162,11 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
if ( in_array( $this->requires, array( 'min_amount', 'either', 'both' ), true ) ) {
$total = WC()->cart->get_displayed_subtotal();
if ( WC()->cart->display_prices_including_tax() ) {
$total = $total - WC()->cart->get_discount_tax();
}
if ( 'no' === $this->ignore_discounts ) {
$total = $total - WC()->cart->get_discount_total();
if ( WC()->cart->display_prices_including_tax() ) {
$total = $total - WC()->cart->get_discount_tax();
}
}
$total = NumberUtil::round( $total, wc_get_price_decimals() );