Skip to content

fix(storefront): STRF-14923 Persist lang selector with items in cart - #2750

Open
Jwatzkin77 wants to merge 2 commits into
masterfrom
STRF-14923
Open

Jwatzkin77 wants to merge 2 commits into
masterfrom
STRF-14923

Conversation

@Jwatzkin77

@Jwatzkin77 Jwatzkin77 commented Nov 11, 2026 •

Copy link
Copy Markdown

What?

Currently the cart locale selector in stencil storefronts does not update the cart locale/language once a single item is in the cart. This is a recommended resolution to fix that behavior

Requirements

  • [ - templates/layout/base.html (line 43)

    • The gqlToken inject, right after the cartId inject on line 42
  • assets/js/theme/global.js (lines 8, 19, 24)

    • The cartLocaleSwitcher import (8)
    • gqlToken in the this.context destructuring (19)
    • The call after languageSelector() (24)
  • assets/js/theme/global/language-selector.js (lines 34–78)

    • The mutation string (35)
    • updateCartLocale() (45)
    • The exported cartLocaleSwitcher() (60)
    • The click handler on the a[data-locale-code][data-warning] links, starting at line 63 ] CHANGELOG.md entry added (required for code changes only)

Tickets / Documentation

Screenshots (if appropriate)

EN_IT.mov

Example Image

IT_EN.mov

Note

Medium Risk
Adds client-side GraphQL cart mutations using an injected Storefront API token; failed updates are ignored while navigation still proceeds, which could briefly desync cart locale from the selected language.

Overview
Persists the cart locale when shoppers change language while the cart has items. The layout now injects gqlToken so global init can run a new cartLocaleSwitcher alongside the existing language selector.

On clicks of language links that carry data-warning (locale switch warning), the handler calls the Storefront GraphQL updateCartLocale mutation with the current cartId, then redirects to the switch URL even if the request fails so the UI never blocks the language change.

Reviewed by Cursor Bugbot for commit a1a547e. Bugbot is set up for automated code reviews on this repo. Configure here.

@Jwatzkin77
Jwatzkin77 requested a review from a team as a code owner November 11, 2026 20:56

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit abec23f. Configure here.

* Updates the active cart's locale before following a language switch link
*/
export function cartLocaleSwitcher(cartId, token) {
if (!cartId) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cart locale not updated after add-to-cart

Medium Severity

cartLocaleSwitcher returns immediately when cartId is missing at page load, and it is only invoked from Global.onReady. After an AJAX add-to-cart, currencySelector is re-initialized with the new cart ID, but cartLocaleSwitcher is not, so the cart locale is not persisted if the shopper switches language on the same page.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit abec23f. Configure here.

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