Description
Preconditions and environment
- Magento version: 2.4.x
- Anything else that would help a developer reproduce the bug:
Steps to reproduce
-
Create the first cart price rule:
Rule Information:
Active: Yes
Coupon: Specific Coupon
Coupon Code: 50OFF
Priority: 0
Condition: None
Actions
Apply: Percent of product price discount
Discount Amount: 50%
Maximum Qty Discount is Applied To: 0
Discount Qty Step (Buy X): 0
Apply to Shipping Amount: No
Discard subsequent rules: Yes -
Create the second cart price rule
Rule Information:
Active: Yes
Coupon: No Coupon
Priority: 1
Condition:
If trial SKU is in cart
Actions
Apply: Percent of product price discount
Discount Amount: 100%
Maximum Qty Discount is Applied To: 1
Discount Qty Step (Buy X): 0
Apply to Shipping Amount: Yes
Discard subsequent rules: Yes -
Add to cart 2 products: first product = trial SKU, second product = non-trial SKU.
The second rule applies
Trial SKU price: $20
Non-trial SKU price: $100
Shipping: $10
Subtotal: $130
Discount: -$30.00 -
Apply Discount Code: 50OFF
The first rule is applied correctly but the second rule's shipping discount is applied incorrectly
Trial SKU price: $20
Non-trial SKU price: $100
Shipping: $10
Subtotal: $130
Discount: -$70
Expected result
Discount in step 4 should be $60
Actual result
Discount in step 4 is incorrect: $70
Additional information
This seems to be a problem in Magento\SalesRule\Model\Validator::processShippingAmount
Changing lines 334
foreach ($this->getRules($address) as $rule) {
/* @var Rule $rule */
if (!$rule->getApplyToShipping() || !$this->validatorUtility->canProcessRule($rule, $address)) {
continue;
}
to
foreach ($this->getRules($address) as $rule) {
/* @var Rule $rule */
if (!$rule->getApplyToShipping()) {
if ($rule->getStopRulesProcessing()) {
break;
}
continue;
}
if (!$this->validatorUtility->canProcessRule($rule, $address)) {
continue;
}
seems to fix the issue.
Release note
Discard subsequent cart price rules for shipping amount discounts
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S1 - Affects 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
Type
Projects
Status