Repository navigation
fix(cart): sum line discount amounts numerically - #965
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
This branch has not been deployed
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
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.
Line discount amounts returned by the Storefront API are strings. Adding them directly to the accumulator concatenates multiple amounts:
2.00and3.00produce02.003.00. Subtracting that value from the full price produces NaN, which is displayed as$0.Convert each amount to a number when accumulating the discount total. Individual discount labels retain their existing formatting. Include a regression for a $20 line with $2 and $3 allocations across ENTITLED and EXPLICIT target selections, expecting a $15 line price, and a patch changeset.
Testing and validation
pnpm test(lint plus the testem suite in headless Chrome) passes: 813 tests, 0 failures.With the new regression in
test/unit/cart/cart.jskept andsrc/components/cart.jsreverted tomain, the same suite has 1 failure (812 passed). It is the new case: the line price is rendered as$0and the$20.00full price is missing. Restoring the fix makes it pass.This change was generated with assistance from OpenAI Codex.