Fixed: Discard rule for Shipping amount#40869
Conversation
|
Hi @aasim110. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
@magento run all tests |
|
@engcom-Bravo Could you review this as WebAPI Tests failures are not related to this PR |
|
@magento run WebAPI Tests |
Root Cause
In processShippingAmount(), the original code combined getApplyToShipping() and canProcessRule() in a single condition with continue. When a rule had applyToShipping=false and stopRulesProcessing=true, the method would continue to the next rule instead of breaking, allowing subsequent lower-priority rules to incorrectly apply their shipping discounts
The FIx
The fix splits the condition so that getStopRulesProcessing() is checked before continuing past a non-shipping rule:
Description (*)
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
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