-
Notifications
You must be signed in to change notification settings - Fork 270
2 discount bug fixes (multiple discounts + shipping discounts) #1039
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
878bc8c to
f4b3f4b
Compare
21fc47a to
ee368bb
Compare
kdaviduik
commented
Jun 20, 2025
ee368bb to
b2da846
Compare
kdaviduik
commented
Jun 20, 2025
…plicable A discount code can be added to a cart but might not be `applicable`. In that case, the code will appear in the `discountCodes` array, but there won't be any discount allocations. Since we were using discount allocations to determine which discount codes existed, we would end up inadvertently removing discount codes that were added but not `applicable`.
We're going to use this in the next commit. Separating out this change makes the diffs much easier to read
b2da846 to
40b0e8a
Compare
kdaviduik
commented
Jun 20, 2025
kdaviduik
commented
Jun 20, 2025
kdaviduik
commented
Jun 20, 2025
juanpprieto
reviewed
Jun 20, 2025
11c9298 to
c627b05
Compare
Our previous discount mapping logic did not properly map shipping discounts - they were treated the same as order-level discounts, but behave differently. Unlike order-level discounts (which must get mapped onto line items), shipping discounts should ONLY appear in the `checkout.discountApplications` array. Importantly, if a shipping discount has been added but there is no shipping address known, the Cart APIs behave differently than the Checkout APIs and we therefore have no way of knowing the value, target type, etc. This information was returned by the Checkout APIs in the `checkout.discountApplications` array, but now we cannot return shipping discounts in that array if we don't have a shipping address.
c627b05 to
245726e
Compare
juanpprieto
approved these changes
Jun 24, 2025
Contributor
juanpprieto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, thanks LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Nicer diffs if you review commit by commit (and without whitespace diffs!) :)
applicable. In that case, the code will appear in thediscountCodesarray, but there won't be any discount allocations.applicable.checkout.discountApplicationsarray.checkout.discountApplicationsarray, but now we cannot return shipping discounts in that array if we don't have a shipping address.