Shop Currency in theme.liquid

Highlighted
New Member
7 0 0

Can anyone please tell me, how do you do the following:

 

Set a USD currency in theme.liquid? Currently its defaulting to AUS, and we can use a selector but I want to know the code to set the currency on pageload.

 

shopCurrency: {{ shop.currency | json }}

0 Likes
Highlighted
New Member
7 0 0

Thanks but nope, not what I'm looking for in terms of response. I want to know the code to set a currency on page load.

0 Likes
Highlighted
Excursionist
25 2 4

I am not fully understand your need. Do you want to force your store to display currency in USD? 

You could enable the multi-currency checkout from Shopify Payments. Then you could force your store redirect to the page with USD.

Something like yourdoamin.com/?currency=USD

0 Likes
Highlighted
New Member
7 0 0
Yes just like the URL to set the currency to USD. How can you do that in liquid?
0 Likes
Highlighted
Excursionist
25 2 4

Do you want you customer to be redirected on their first visit, or all their visit.

0 Likes
Highlighted
New Member
7 0 0
Okay let me explain:
I have a if statement that is looking at the domain string, if the domain is .com or .com.au. I have a bunch of changes happening based on that statement. The default shopify setting is set to everything Australian. We don’t want to create another shopify store for the US. We have currency pull down and the app that looks at the IP address and ask would you like to switch.

So, I want to avoid using the app to ask the question, so if you are on the .com domain I want to apply the currency to USD for the user without a dialogue.
0 Likes
Highlighted
Excursionist
25 2 4

If you have multi-currency checkout enabled from shopify payment. You could add this script inside you if statement,

window.location.href = window.location.href + "?currency=USD"
0 Likes
Highlighted
New Member
7 0 0
Cool! I’ll try adding that tomorrow. Thx.
0 Likes
Highlighted
Excursionist
25 2 4

You may want to edit your if statement a little bit more. Like another if statement inside, otherwise this will result an endless loop.

 

For example.

if (window.Shopify.currency.active != "USD") {
  window.location ......
}
1 Like