Is the file run on the storefront or is it a node.js application? If it's storefront you can just use the methods I mentioned that are a part of the Shopify AJAX API.
If it's a node app you can hit /admin/shop.json which will include fields like currency, money_format and money_with_currency_format.
There isn't a public API for what you are looking to do. The merchant can change whatever they want their formatting to look like in the admin and this is properly reflected via those Shopify AJAX API calls.
Here's admin settings I set in my Shop:
Here's the results from some calls to the Shopify AJAX API
I don't know where the official documentation is, but someone put together a little Shopify Javascript API sandbox thing you can play around with.
I'm currently working on Debut (not an app) and have came across this issue. I had access to theme.Currency.formatMoney(); but not the money format.
Digging a bit into the code I found that there is a function that exposes this. It's called theme.moneyFormatWithCurrency
So, long story short, if you want to format money and you're using AJAX, do this:
theme.Currency.formatMoney(123, theme.moneyFormatWithCurrency);
Hope it helps.
User | Count |
---|---|
13 | |
12 | |
10 | |
8 | |
7 |