Skip to content

Fixed: Discard rule for Shipping amount#40869

Open
aasim110 wants to merge 1 commit into
magento:2.4-developfrom
aasim110:37985-discard-rules-shipping-amount
Open

Fixed: Discard rule for Shipping amount#40869
aasim110 wants to merge 1 commit into
magento:2.4-developfrom
aasim110:37985-discard-rules-shipping-amount

Conversation

@aasim110

Copy link
Copy Markdown
Contributor

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)

  1. Fixes Discard subsequent rules for shipping amount #37985

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

@m2-assistant

m2-assistant Bot commented Jun 10, 2026

Copy link
Copy Markdown

Hi @aasim110. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@ct-prd-pr-scan

Copy link
Copy Markdown

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.

@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run all tests

@aasim110

Copy link
Copy Markdown
Contributor Author

@engcom-Bravo Could you review this as WebAPI Tests failures are not related to this PR

@aasim110

Copy link
Copy Markdown
Contributor Author

@magento run WebAPI Tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jun 16, 2026
@github-project-automation github-project-automation Bot moved this to Pending Review in Pull Requests Dashboard Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Discard subsequent rules for shipping amount

2 participants