Skip to content

"Subtotal (Excl. Tax)" condition for Cart rule is not working for FREE Shipping #36760

@MagePsycho

Description

@MagePsycho

Preconditions and environment

  • Magento version 2.4.3-p2
  • Enable Tablerate shipping

Steps to reproduce

Backend

  1. Create a cart rule with following
  • {{{}Conditions{}}}: Subtotal (Excl. Tax) is equals or greater than 100
  • {{{}Actions{}}}: Free Shipping = For matching items only
  1. Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Storefront

  1. Add items to the cart to make a subtotal of 105
  2. Apply the coupon XYZ to get 10$ OFF

Expected result

The shipping fee should not be 0 (i.e. FREE shipping cart rule should not be applied)

Actual result

The shipping fee is showing 0 (i.e. FREE shipping cart rule is applied)

Additional information

!https://user-images.githubusercontent.com/1205071/213676297-f3145d58-e179-47fb-aebc-19d5edb4e47a.png|width=593,height=348!

Quick n Dirty Solution

Step debugging showed that the value provided by the $address->getData('base*subtotal_with*discount') is not correct:
!https://user-images.githubusercontent.com/1205071/213677260-afb0ac81-6fd1-450a-a945-3212f479f63c.png|width=509,height=152!

So ended up tweaking as below:

\Magento\OfflineShipping\Model\SalesRule\Calculator::processFreeShipping()
``{{
public function processFreeShipping(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
{
$address = $item->getAddress();

$item->setFreeShipping(false);

foreach ($this->_getRules($address) as $rule) {

/* Quick Fix - Start /
$address->setBaseSubtotalWithDiscount($address->getBaseSubtotal() + $address->getBaseDiscountAmount());
/
Quick Fix - End */

/* @var $rule \Magento\SalesRule\Model\Rule */
if (!$this->validatorUtility->canProcessRule($rule, $address))

{ continue; }

}}``

Release note

No response

Triage and priority

  • < ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ > Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: Cart & CheckoutComponent: CheckoutIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReported on 2.4.3-p2Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions