fbpx

Add 30% to your sales 💰 with upsells!Get App

Get 30% sales increase 💰 with upsells!Get App

How to Auto Change Currency Based on Customers Location in Shopify

How to Auto Change Currency Based on Customers Location in Shopify

Last Updated on July 13, 2021 by LAUNCHTIP

How to auto change currency based on customers’ locations in Shopify

If you get a lot of international customers, it only makes sense to display the currency according to their locality. It will make your customers feel at home while saving their time that they’d otherwise have to spend on converting the USD to their country’s currency. 

In this guide, we discuss a method to auto change the currency based on your customers’ location in Shopify. Keep in mind that this method requires a currency switcher. So, you must be using it. Plus, the method also requires you to use JQuery – almost all Shopify store owners do. 

How to auto change currency in Shopify

  • Go to the theme.liquid in your Shopify admin and paste the following code. 
<script>

   jQuery.getJSON('http://freegeoip.net/json/';, function(location) {

   // check if a user is from Israel

  if (location.country_code == 'IL') {

    $("#currencies").val("ILS");

    $("#currencies").change();

  }

  // add more countries here

}

</script>
  • You must add the currency in theme settings, allowing it to be changed when someone comes to your store from a different location. 
  • If the script mentioned above does not work for you, use this altered code instead: 
<script>

jQuery.ajax( { 

  url: '//freegeoip.net/json/', 

  type: 'POST', 

  dataType: 'jsonp',

  success: function(location) {

    // If the visitor is browsing from Canada.

    if (location.country_code === 'CA') {

      // Change currency to CAD.

    $("#currencies").val("CAD");

    $("#currencies").change();

    }

  }

} );

<script>

After doing this, you can check if it’s working. To do that, use the Hola extension in Chrome to trick the site into believing that you’re from another country. This way, you can check if the currency changes automatically when you come to the Shopify store. 

If none of these scripts seem to work for your store, get in touch with a Shopify expert for more information on the subject. 

 

Related Posts
Leave a Reply