Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Clear previous line adjustments before testing order item promotions #3320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

putermancer
Copy link

Description

OrderCalculator#applyOrderPromotions clears out all existing DISTRIBUTED_ORDER_PROMOTIONs before testing promotions. applyOrderItemPromotions does not currently do the same, the result of which is that when conditions / actions are encountered, previous adjustment data may be present on the line items in question.

My specific use case was when creating a promotion of the type "apply a bulk purchase discount, but only to items that aren't already discounted," e.g. when there are 10+ of a product and they aren't already discounted.

Without this change: upon reaching 10 items, the line items become discounted. Upon reaching 11 items, the test for "are there adjustments applied" returns true (the previous adjustment), resulting in the discount being removed. Bump the quantity to 12 and it applies again.

With this change: it works properly when reaching 10, 11, 12, and on.

Breaking changes

No.

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • (N/A) I have updated the README if needed

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Jan 16, 2025 9:16pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant