Hello Magento Friends,

In this blog, we will learn about How to Add Custom Currency to Magento 2.

Magento 2 is a powerful e-commerce platform that provides a plethora of features for managing online stores. One such feature is the ability to handle multiple currencies, which is crucial for businesses operating in international markets. Merchants can also add a currency switcher in store frontend to improve user’s shopping experience.

While Magento 2 supports a variety of currencies out of the box, there may be instances where you need to add a custom currency that isn’t natively supported. This could be for a loyalty program, a custom reward system, or even a unique virtual currency. 

This guide will walk you through the steps to add a custom currency to your Magento 2 store.

Steps to Add Custom Currency to Magento 2:

Step 1: Create a registration.php file at the following path.

/app/code/Vendor/Extension/registration.php

Now, add the below given code

Step 2: Create Currencybundle.php file at the below path.

/app/code/Vendor/Extension/Override/Currencybundle.php

Then add the code as follows

Step 3: Create di.xml file at the below-mentioned file path.

/app/code/Vendor/Extension/etc/di.xml

After that add the following piece of code

Step 4: Create Localeconfig.php file at the below-given file path.

/app/code/Vendor/Extension/Plugin/Localeconfig.php

Now, include the following code snippet

Step 5: Create Configplugin.php file at the path given below.

/app/code/Vendor/Extension/Plugin/Configplugin.php

Then after, add the below code

Step 6: Create Amount.php file at the following path.

/app/code/Vendor/Extension/Plugin/Framework/Pricing/Render/Amount.php

Now, include the following code

Step 7: Create Pricecurrency.php file at the below-mentioned path.

/app/code/Vendor/Extension/Plugin/Directory/Model/Pricecurrency.php

And then add the code as given below

Step 8: Create Format.php file at the path given below.

/app/code/Vendor/Extension/Plugin/Framework/Locale/Format.php

And add the code as follows

Output:

You can see that your custom currency has been added to the backend currency setup configuration.

backend custom currency

The custom currency will be displayed on the frontend product page.

product page custom currency

The custom currency will also be displayed on the frontend category page.

category page custom currency

Conclusion:

By following this guide, you can extend the capabilities of your Magento 2 store to support any custom currency, enhancing your store’s flexibility and catering to a broader audience.

Share the tutorial with your friends and stay in touch with us for more such Magento 2 custom solutions.

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]