Hi,
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.