Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have issues when switching the country in combination with language subfolders:
Assume I have Canada (CA) as currently selected country and French as language. Then my URL looks like this: https://my-shop.myshopify.com/fr, and in the background the Liquid variable `localization.country.iso_code` has the value `CA`. When I set the URL parameter to switch the country, like in https://my-shop.myshopify.com/fr?country=BE, the page reloads and correctly shows the new country and currency. But as soon as I don't use the parameter again (like this: https://my-shop.myshopify.com/fr), Canada is shown again. There is no permanent assignment.
This behavior is only shown in a productive/merchant shop and only if I have a language subfolder. In my dev environment or in production with no subfolder (like https://my-shop.myshopify.com), the new country is permanently assigned as soon as I used it once as URL parameter.
I switched to the form-based way of letting the user select the country:
{% form 'localization' , id: 'HeaderCountryForm' , class: 'localization-form' %} <select name="country_code"> {%- for country in localization.available_countries -%} <option value="{{ country.iso_code }}" {%- if country.iso_code == localization.country.iso_code %} selected{% endif %}> {{ country.name }} ({{ country.currency.symbol }}) </option> {%- endfor -%} </select> <button type="submit">Update Country</button> {% endform %}
and even there, in my production environment, when pressing the 'Update Country' button and I have a language subfolder in place, the language doesn't update.
I used the browser developer tools to check the network traffic:
In my dev environment, the response header of the page contains a field `Content-Language: fr` whereas in my prod environment, the field contains `Content-Language: fr-BE`. So the response seems to be wrong here.
I also see some `preloads.js?locale=fr-BE` in dev (good) which is `preloads.js?locale=fr-CA` in prod (not good).
Could someone from the Shopify developers please have a look into this?
Ping 😉
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024