For stores with multi-currency support enabled, how to find customer's presentment currency via JS ?

1 0 0



I am trying to build an app that uses a scriptTag to send an AJAX request (via APP PROXY) to fetch store data and update some DOM fragment on the online store accordingly. 

I want to pass customer's presentment currency in the AJAX request to ensure correct prices are shown to the customer.

How can I access this piece of information in the scriptTag's JS ? Here are some options I considered :

a) Render liquid template in the response to APP PROXY. However, this doesn't work as it renders entire HTML page . In my case, I am simply passing some JSON data back to the client via APP PROXY. 

b) Use cart.JS endpoint on AJAX API . Is this a valid option ? Does it work for all stores ? Does it need any additional oauth scopes ?

c) I noticed there is Shopify global JS variable set on client. It has information about customer's presentment currency (Shopify.currency). Can I rely on this ? Is this guaranteed to be available across any theme / any store ? Is there any official documentation about its use ?


Are there any other approaches ? Alternatively, can Shopify start passing customer's local presentment currency as a header or query parameter in the APP PROXY request forwarded to the app ? This would be really awesome. 

Or can shopify allow partial rendering of liquid templates in APP PROXY responses sent by an app ?


Please help.


Replies 2 (2)

Shopify Staff
1561 81 341

cart.js via the ajax API is available on all stores without requiring authentication.


That said, I've seen this problem raised before. You're not going to have an easy time doing this, since we don't really surface the exact calculation anywhere. I'm told the global Shopify object, while everpresent, can't be relied upon for a specific conversion since we account for fees and etc in the background.


I would like to know more about your use case so I can raise it internally, in the interest of making it easier for partners to be aware of these details if it's something we decide we can do.


If anyone in the community has come up with some kind of workaround though, I'd be interested to know.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Shopify Partner
6339 579 1343

Are yo

@Alex wrote:

...since we don't really surface the exact calculation anywhere

@chintndo wrote:

I want to pass customer's presentment currency in the AJAX request to ensure correct prices are shown to the customer.


@chintndo yes please expand a bit not clear on what your doing , Like do you just need the 3 character currency code (USD,EUR,etc) or the conversion rates?  /cart.js has a currency field set to the user.


Is another option?  D) a heuristic to check prices in the dom versus the shop


Also see the migration guide if you can make another call first "To retrieve the presentment_prices property on variants, include the request header 'X-Shopify-Api-Features': 'include-presentment-prices'.". 

Save time & money ,Ask Questions The Smart Way

Confused? Busy? Get the solution you need

Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to