Get store base currency shopify

Viewed 3568

I am building an app for Shopify. My store has EUR as the base currency and supports different currencies such as USD, NZD,.. (I refer it as active currency).

I can get active currency with the javascript window.Shopify.currency.active and also the rate window.Shopify.currency.rate. How can I get the base currency symbol?

4 Answers

Shopify provides the Currency object depending on the theme page.

You can use {{ cart.currency.symbol }} and {{ checkout.currency.symbol }} in Cart page and Checkout page respectively.

For any other page, you can use the Shop object to get the currency by using {{ shop.currency }}.

Try theme.moneyFormat, it works for me:

var currentCurrent = theme.moneyFormat;

Whenever anyone changes currency, it will give current currency with symbol.

Step 01:
- create ajax API to get cart info  
setTimeout(function() {
    $.getJSON('/cart.js', function(cart) {
        // your code here
        });
}, 200);  
    
Step 02:
- get currency form ajax and put any variable
setTimeout(function() {
    $.getJSON('/cart.js', function(cart) {
        var currency=cart.currcy;   
        });
}, 200);  

Step 03:
- push the currency variable, where you want to show.
so the total code is:

setTimeout(function() {
    $.getJSON('/cart.js', function(cart) {
        var currency=cart.currcy;           
        $('.total-cost').text(currency+ ' '+((product_total_price*0.01).toFixed(2)));
    });
}, 200);  

Note: After successfully adding this code, you need to change your currency on admin.
check screenshot:(Admin>settings>store details>currency change formattings)
https://prnt.sc/jo-MKnDtM5kE
Related