Skip to content

add currency selector #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This is a list of useful Shopify Snippets that I often reference while developin
* [Recommend related products](https://help.shopify.com/themes/customization/products/recommend-related-products)
* [Show More Products from a Vendor](#show-more-products-from-a-vendor)
* [Strip empty tags from article excerpt](#strip-empty-tags-from-article-excerpt)
* [Multiple currency selector](#multiple-currency-selector)

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

## Multiple currency selector

```liquid
{% form 'currency' %}
{{ form | currency_selector }}
{% endform %}
```

```liquid
{% form 'currency' %}
<select name="currency">
{% for currency in shop.enabled_currencies %}
{% if currency == cart.currency %}
<option selected="true" value="{{ currency.iso_code }}">{{currency.iso_code}} {{currency.symbol}}</option>
{% else %}
<option value="{{ currency.iso_code }}">{{currency.iso_code}} {{currency.symbol}}</option>
{% endif %}
{% endfor %}
</select>
{% endform %}
```

```js
$('.shopify-currency-form select').on('change', function() {
$(this)
.parents('form')
.submit();
});
```

## License

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