Last active
July 14, 2020 16:48
-
-
Save ihorduchenko/2989cb53acaddf16cfa0dda4a231f021 to your computer and use it in GitHub Desktop.
Shopify built in currency switcher
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
{%- form 'localization', class: 'selectors-form' -%} | |
<select id="currency-list"> | |
{% for currency in form.available_currencies %} | |
<option{% if currency.iso_code == form.current_currency.iso_code %} selected="true"{% endif %} | |
data-name="{{ currency.name }}" value="{{ currency.iso_code }}"> | |
{%- if currency.symbol -%}{{ currency.symbol }}{%- endif -%} {{ currency.iso_code }} | |
</option> | |
{%- endfor -%} | |
</select> | |
<input id="currentCurrencyInp" type="hidden" name="currency_code" value="{{ form.current_currency.iso_code }}"> | |
{%- endform -%} | |
<script> | |
$('#currency-list').on('change', function() { | |
var vall = $(this).val(); | |
$('#currentCurrencyInp').val(vall); | |
setTimeout(function() { | |
$('#localization_form').submit(); | |
}, 100); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment