Skip to content

fix(cart): sum line discount amounts numerically - #965

Open
pcbeingused33 wants to merge 1 commit into
Shopify:mainfrom
pcbeingused33:fix/combined-line-discounts
Open

pcbeingused33 wants to merge 1 commit into
Shopify:mainfrom
pcbeingused33:fix/combined-line-discounts

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Nov 18, 2026 •

Copy link
Copy Markdown

Line discount amounts returned by the Storefront API are strings. Adding them directly to the accumulator concatenates multiple amounts: 2.00 and 3.00 produce 02.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.js kept and src/components/cart.js reverted to main, the same suite has 1 failure (812 passed). It is the new case: the line price is rendered as $0 and the $20.00 full price is missing. Restoring the fix makes it pass.

This change was generated with assistance from OpenAI Codex.

@pcbeingused33
pcbeingused33 requested a review from a team as a code owner November 18, 2026 03:32

This branch has not been deployed

No deployments
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