Skip to content

Commit b0ad1ba

Browse files
authored
Merge pull request #2 from keidarcy/add/add_currency_selector
add currency selector
2 parents bc03406 + 40624bd commit b0ad1ba

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This is a list of useful Shopify Snippets that I often reference while developin
2222
* [Recommend related products](https://help.shopify.com/themes/customization/products/recommend-related-products)
2323
* [Show More Products from a Vendor](#show-more-products-from-a-vendor)
2424
* [Strip empty tags from article excerpt](#strip-empty-tags-from-article-excerpt)
25+
* [Multiple currency selector](#multiple-currency-selector)
2526

2627
## Add Custom Badge on Products using product tag
2728
This code adds a limited badge on products with "limited" tag on them. Add this in product template.
@@ -214,6 +215,36 @@ Strip out empty p and span tags
214215
{{ article.excerpt | strip_html }}
215216
```
216217

218+
## Multiple currency selector
219+
220+
```liquid
221+
{% form 'currency' %}
222+
{{ form | currency_selector }}
223+
{% endform %}
224+
```
225+
226+
```liquid
227+
{% form 'currency' %}
228+
<select name="currency">
229+
{% for currency in shop.enabled_currencies %}
230+
{% if currency == cart.currency %}
231+
<option selected="true" value="{{ currency.iso_code }}">{{currency.iso_code}} {{currency.symbol}}</option>
232+
{% else %}
233+
<option value="{{ currency.iso_code }}">{{currency.iso_code}} {{currency.symbol}}</option>
234+
{% endif %}
235+
{% endfor %}
236+
</select>
237+
{% endform %}
238+
```
239+
240+
```js
241+
$('.shopify-currency-form select').on('change', function() {
242+
$(this)
243+
.parents('form')
244+
.submit();
245+
});
246+
```
247+
217248
## License
218249

219250
Licensed under the [MIT](https://github.com/vikrantnegi/shopify-code-snippets/blob/master/LICENSE).

0 commit comments

Comments
 (0)