Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
{% if settings.show_multiple_currencies %}
{{ "//" | script_tag }}
{{ "jquery.currencies.min.js" | asset_url | script_tag }}
Currency.format = '{{ settings.currency_format | default: 'money_with_currency_format' }}';
var shopCurrency = '{{ shop.currency }}';
/* Sometimes merchants change their shop currency, let's tell our JavaScript file */
Currency.moneyFormats[shopCurrency].money_with_currency_format = {{ shop.money_with_currency_format | strip_html | json }};
Currency.moneyFormats[shopCurrency].money_format = {{ shop.money_format | strip_html | json }};
/* Default currency */
var defaultCurrency = '{{ settings.default_currency | default: shop.currency }}';
/* Cookie currency */
var cookieCurrency =;
/* Fix for customer account pages */
jQuery('').each(function() {
/* Saving the current price */
jQuery('').each(function() {
jQuery(this).attr('data-currency-{{ shop.currency }}', jQuery(this).html());
// If there's no cookie.
if (cookieCurrency == null) {
if (shopCurrency !== defaultCurrency) {
Currency.convertAll(shopCurrency, defaultCurrency);
else {
Currency.currentCurrency = defaultCurrency;
// If the cookie value does not correspond to any value in the currency dropdown.
else if (jQuery('[name=currencies]').size() && jQuery('[name=currencies] option[value=' + cookieCurrency + ']').size() === 0) {
Currency.currentCurrency = shopCurrency;
else if (cookieCurrency === shopCurrency) {
Currency.currentCurrency = shopCurrency;
else {
Currency.convertAll(shopCurrency, cookieCurrency);
jQuery('[name=currencies]').val(Currency.currentCurrency).change(function() {
var newCurrency = jQuery(this).val();
Currency.convertAll(Currency.currentCurrency, newCurrency);
var original_selectCallback = window.selectCallback;
var selectCallback = function(variant, selector) {
original_selectCallback(variant, selector);
Currency.convertAll(shopCurrency, jQuery('[name=currencies]').val());
$('body').on('ajaxCart.afterCartLoad', function(cart) {
Currency.convertAll(shopCurrency, jQuery('[name=currencies]').val());
{% endif %}

carolineschnapp commented May 17, 2012

On line 42, is when you reload page when changing from any-currency-other-than-shop-currency back to shop currency. To avoid rounding errors.


carolineschnapp commented Aug 5, 2012

There's no more any need to reload the page when converting to the shop's currency. The currency conversion code has been refactored on August 5th to handle conversions 'lost in translation'.

stcqu commented Aug 22, 2013

I had trouble with this script running before my page was entirely loaded. This led to some currencies being untranslated. I was able to fix this by running the script on the document load event.

I had a similar problem as squebe when using the "Simple" Shopify theme - most elements were translated, but not all.

I resolved it by putting this on line 7:

$(document).ready(function() {

and closing the function by putting this on line 69:


Hopefully that's clear enough for any non-coders to apply.

Hi There,

above stuartellis [[[$(document).ready(function()]]] solution works well in all browser, but Safari.

In Product Page, I find the product currency will jump back to the default currency after the page is loaded (you will see the price jump in 1s). it only happens on safari (MAC), all other browsers do not have this issue. it would be great if anyone can help me out here. Big thanks

Here is a link from my client:

Hi There, Im trying to figure out if is possible to round the second currency and resting the value of 1.

Example, where USD is the default currency and COP my informative currency.

I would like to show this result $234.589 COP to $235.000 COP and resting 1 or 10 would be $234.999 COP or $234.990 COP

I Appreciate information! Thank you!

Hey there! Newb question. Is there a way to change the users cookie settings using a url parameter for this e.g ?cur=USD


Hi i am getting a issue with code when Change Currency it did not change instantly i have to click on cart icon and then it change currency
please help its urgent


I think I found a bug in following Use Case:

  1. user enters the website first time
  2. user changes the currency from default USD to EURO
  3. user reloads the page
  4. the currency cookie remembers the previously choosen EURO value and automatically switches the prices to EURO
  5. user wants to switch the prices back to the USD but he can't, if he tries to switch to default USD value the prices won't
    change, they will remain the Euro. Even if he changes the currency to for example GBP for a moment and then tries to click on USD the prices will switch back to Euro instead of USD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment