FROM CACHE - en_header

Get currency symbol using javascript?

captainzero
Shopify Partner
41 0 9

My app show product recommendation in product page, the response from my app have price without currency symbol. Is there any way to get shop currency symbol through javascript.

 

I can get shop currency via Shopify.currency but i need currency symbol.

 

Is there any way?

Replies 5 (5)
Josh
Shopify Staff
Shopify Staff
1134 83 217

Hey there, 

 

I'm not aware of any way to do this with javascript, but it is available on the shop object at `/admin/shop.json` under the `money_with_currency_format` field. 

 

You may be able to utilize that, though admittedly it will fall short on any Shopify Plus shops that are using multiple currencies. If that won't be a suitable solution for you, my only other recommendation coming to mind would be to continue to use Shopify.currency but then map the currency names to their associated symbols manually. 

 

 

Josh | 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

captainzero
Shopify Partner
41 0 9

i can get money_format from user details so can it will be like '${amount}'

 

Is it a good way to remove {amount} from that string and get the symbol?

 

@Josh 


@Josh wrote:

Hey there, 

 

I'm not aware of any way to do this with javascript, but it is available on the shop object at `/admin/shop.json` under the `money_with_currency_format` field. 

 

You may be able to utilize that, though admittedly it will fall short on any Shopify Plus shops that are using multiple currencies. If that won't be a suitable solution for you, my only other recommendation coming to mind would be to continue to use Shopify.currency but then map the currency names to their associated symbols manually. 

 

 


 

Kyon147
Shopify Partner
7 1 1

For anyone who stumbles on this.

You can just do:

var symbol = theme.moneyFormat.split('{')[0];

This will split the string down into parts and we just grab the first one which is the symbol.

sravans
Shopify Partner
23 1 6

@Kyon147 wrote:

For anyone who stumbles on this.

You can just do:

var symbol = theme.moneyFormat.split('{')[0];

This will split the string down into parts and we just grab the first one which is the symbol.


This doesn't seem to work for all themes. Breaking in Brooklyn theme, "theme.moneyFormat undefined".