Skip to content

🐛 fix(HostedCart): refresh minicart URL when persistKey changes (#685)#740

Open
acasazza wants to merge 9 commits intomainfrom
refactor/hosted-cart-resolved-order-id
Open

🐛 fix(HostedCart): refresh minicart URL when persistKey changes (#685)#740
acasazza wants to merge 9 commits intomainfrom
refactor/hosted-cart-resolved-order-id

Conversation

@acasazza
Copy link
Copy Markdown
Member

@acasazza acasazza commented Apr 8, 2026

Changes

🐛 Fix: HostedCart — refresh minicart URL when persistKey changes (Closes #685)

  • Added loadedOrderIdRef to track which order ID the current src was built for
  • Added persistKey to useEffect dependency array so the cart URL recomputes when the storage key changes
  • Fixed setOrder org-config lookup to use order?.id ?? orderId consistently
  • Added regression test in specs/orders/hosted-cart.spec.tsx

📦 Deps: bump @commercelayer/organization-config to ^2.8.4

  • Updated from ^2.4.0 to ^2.8.4 to unlock new ConfigParams fields: identityType, clientId, scope, returnUrl, resetPasswordUrl, skuListId, skuId, lang, token

✨ Feat: MyIdentityLink — pass all identity params to getOrganizationConfig

  • Forwards identityType, clientId, scope, returnUrl, resetPasswordUrl to getOrganizationConfig
  • Moved getDomain(endpoint) inside the useEffect callback to keep deps clean
  • Fixed useEffect dependency array to include all consumed props

✨ Feat: AddToCartButton — pass skuListId and skuId to getOrganizationConfig

  • Forwards skuListId (from props) and skuId (from SkuChildrenContext) when resolving the cart URL on redirect, enabling org-config URL templates with :sku_list_id and :sku_id placeholders to resolve correctly

♻️ Refactor: HostedCart — resolve order ID once via resolvedOrderId

  • Extracted order?.id ?? localStorage.getItem(persistKey) into a single resolvedOrderId variable at the top of the effect

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for commercelayer-react-components failed.

Name Link
🔨 Latest commit eabda79
🔍 Latest deploy log https://app.netlify.com/projects/commercelayer-react-components/deploys/69d68dfa95a08a000818de85

@acasazza acasazza self-assigned this Apr 8, 2026
@acasazza acasazza added the bug Something isn't working label Apr 8, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

npm i https://pkg.pr.new/@commercelayer/react-components@740

commit: eabda79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing persistKey on OrderStorage does not update the minicart

1 participant