Skip to content

Instantly share code, notes, and snippets.

@mhuegel
Last active March 20, 2024 12:25
Show Gist options
  • Save mhuegel/493014b03c5198c0f1360936c90d5847 to your computer and use it in GitHub Desktop.
Save mhuegel/493014b03c5198c0f1360936c90d5847 to your computer and use it in GitHub Desktop.
Shopify raw localization form
{% comment %}
// CURRENCY PICKER
{% endcomment %}
{% if localization.available_countries.size > 1 %}
{% form 'localization' %}
<select name="country_code" id="country_code__footer" data-submit-on-change>
{% 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.iso_code }}
{{ country.currency.symbol }})
</option>
{% endfor %}
</select>
{% endform %}
{% endif %}
{% comment %}
// LANGUAGE PICKER
{% endcomment %}
{% if localization.available_languages.size > 1 %}
{% form 'localization' %}
<select name="language_code" id="country_code__footer" data-submit-on-change>
{% for language in localization.available_languages %}
<option
value="{{ language.iso_code }}"
{% if language.iso_code == localization.language.iso_code %}
selected
{% endif %}
>
{{ language.name }}
</option>
{% endfor %}
</select>
{% endform %}
{% endif %}
{% comment %}
// JS: AUTO SUBMIT
{% endcomment %}
<script>
$('[data-submit-on-change]').on('change', function () {
$(this).closest('form').submit();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment