Customize Currency Display in Magento 2

Have you ever wondered if it’s possible to modify currency and customize currency display in Magento 2 price boxes? I thought a backend developer should implement this modification, but on the contrary, we are talking about a config change!

Set up store views and locales

Let’s start off by setting up a multi-store view shop in Admin. Go to Stores > All Stores and create store views as indicated below:

Website, store and store views setup
1. Set up a multi-store view shop

Next, we need to set locales for each store view (Stores > Configuration > General > Locale Options > Locale). Let’s keep the English for the default locale and set the Croatian locale for the Croatian store view.

Admin Default Locale
2.1 Set locale for a store view – English
Admin Locale Croatian
2.2 Set locale for a store view – Croatian

Set up store currencies and rates

Next, we need to specify which currencies will be used. For the purposes of this blog post, both store views have the same currencies. In Admin, go to Stores > Configuration > General > Currency Setup > Allowed Currencies and on Default Config, select the following currencies:

  • US dollars (USD)
  • Croatian kuna (HRK)*
Admin Default Currencies
3. Specify currencies

*As of January 1st, 2023, the Croatian national currency is replaced with Euro (€).

In order to have multiple currencies on site, specify currency rates. For the purposes of this blog post, we will use static values. Go to Stores > Currency Rates and set some value:

Currency Rate
4. Specify currency rates

Frontend check of currency configuration

After clearing the cache, open the front end and check if everything is working as expected. Use the following Javascript command in DevTools to show both currencies/store options at the same time:

document.querySelectorAll('.page-header ul.dropdown').forEach(function(dropdown){
dropdown.style.display = 'block';
});

You should see the site setup as indicated below:

Header Dropdowns
5. Check if everything works fine

If we open the storefront in native locale and currency (English/USD and Croatian/HRK), we get the following:

Catalog Prices USD
5.1 Check 1st storefront
Catalog Prices HRK
5.2 Check 2nd storefront

Customize currency symbol’s display

Let’s go back to Admin now and customize the currencies!

By default in Admin (Stores > Currency Symbols), USD has “$” as the currency symbol, whereas HRK has “HRK” as the currency symbol.

Currency Symbols
6. Default currency symbols

Let’s uncheck these checkboxes and set custom symbols (or words), such as:

  • “kuna” for HRK
  • “bucks” for USD

Upon clearing the cache and refreshing the category page, you should see the recent changes:

Prices Bucks
7.1 Customized symbol for USD
Prices kuna
7.2 Customized symbol for HRK

Important things to remember

  • if you are using a custom currency symbol, the product price and currency symbol are glued together (if you check the default Croatian currency display, there is a blank space between the two). Here are two possible solutions:
    • an easier solution is to add blank space to the currency symbol before/after the symbol (” kuna”, “bucks “)
    • complex, but the more stable solution is to contact your backend developer to set the formatting and/or ordering of the price and symbol
  • if a visitor is browsing the catalog in a non-native locale/currency combination (for example English/HRK and Croatian/USD), custom currency change is not applied. This actually makes sense, your visitors may not be familiar with popular currency name (buck for USD) or full currency name (kuna for HRK).
  • if you do customize currency display, it will affect entire M2 installation
    • all frontend segments (catalog pages – PLP/PDP, cart/minicart, checkout, orders page in “My account” section)
    • transactional emails
    • all backend segments (Sales pages in Admin (Orders, Invoices, Credit memos), Dashboard and other), existing order history is also affected!

Hope this article was helpful to you! Feel free leave a comment below if you have any questions! Or just to say something nice 🙂