Repository navigation
Conversation
A shopper who switched to KES saw KES in the cart but USD on the home, shop, category, tag and product pages, and a first visit showed each product's first listed price while the currency picker said KES. Cart responses now set a `dashcommerce_currency` cookie, and the new `shopperCurrency(Astro.cookies)` returns the cart's currency or, before there is a cart, the shop's default. The starter's pages and core's product components use it, and the product page's JSON-LD offer uses the same currency and amount the page shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 6, 2026
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.
What and why
This is the bug half of #96. A shopper who switches to KES sees KES in the cart, but the home, shop, category, tag and product pages still show USD. On a first visit, before there's a cart, every listing shows each product's first listed price (often USD) while the header's currency picker already says KES. The product page's JSON-LD offer has the same problem, so search engines see a price that isn't the one on the page.
Core's
ProductDetails,ProductCardandProductGridalready take acurrencyprop; the starter's pages never pass it. This PR gives pages one place to learn the shopper's currency, and passes it.The visitor-country idea in #96 isn't in this PR. It would plug in at the same point later, if you want it.
Behaviour
dashcommerce_currencycookie (not HttpOnly,SameSite=Lax, 30 days) with the cart's currency. It's display-only: the cart stays the source of truth for pricing.shopperCurrency(Astro.cookies)(new, from@dashcommerce/core/astro) returns the cart's currency, or the shop's default currency (the one a new cart starts in) before there's a cart.storefrontCurrency(Astro.cookies)reads the cookie alone; a malformed or non-ISO value counts as unset.ProductGrid,ProductDetails, the product grid and embed blocks) useshopperCurrencywhen nocurrencyprop is passed;ProductCardfollows the cart cookie.Changes
packages/core/src/routes/cart.ts: acartResponsehelper sets the currency cookie alongside the session cookie (Headers, so bothSet-Cookievalues survive).packages/core/src/astro/currency.ts(new):STOREFRONT_CURRENCY_COOKIE,storefrontCurrency,shopperCurrency; exported from@dashcommerce/core/astro.packages/core/src/astro/components/*:ProductCard,ProductDetails,ProductGrid,ProductGridBlock,ProductEmbedBlockfall back to the shopper's currency.packages/starter/src/lib/price.ts(new) and the five storefront pages.packages/core/README.md, and a changeset (core minor, starter patch).Tests
packages/core/test/storefront-currency-cookie.test.ts(new): the cookie on a new shopper's first cart response (alongside the session cookie), following a currency switch, reading it back, malformed and non-currency values,shopperCurrency's fallback to the shop's default, and that every starter listing and core's grids, blocks and product details use it.All 9 fail without the change. Suites run locally: core 447, paystack 106, flutterwave 137, all passing.
tsc --noEmitand the build are clean; Biome reports nothing new on the changed lines;bun.lockis unchanged.Also tested by hand on a running shop (EmDash 1.6, default currency KES, products priced in KES and USD):
/shop, first visit (no cart)/shopwith a USD cartdashcommerce_currency=KESChecked at 375px wide as well.
Review points