<script>
  $(window).bind("load", function() {
    var cookieCurrency = Currency.cookie.read();
    if(cookieCurrency == null){
      jQuery.ajax({
        url: '//ipinfo.io',
        type: 'GET',
        dataType: 'jsonp',
        success: function(location) {
          if (location.country == 'IN') { // Default shop currency
            $('[name=currency_code]').val('INR');
          } else { // Fallback currency
            $('[name=currency_code]').val('USD');
          }
          // Let the scripts in 'currencies.liquid' handle the rest
          $('[name=currency_code]').change();
          Currency.cookie.write($('[name=currency_code]').val());
          $('[name=currency_code]').closest("form").submit();
        }
      });
    }
  });
</script>


