How to Change Currency Position From Left to Right in Magento 2?

In this article, I’ll show you How to Change Currency Position From Left to Right in Magento 2? In many websites, it is necessary to change the currency position from the left to the right across the entire site. By default, Magento 2 displays the currency symbol on the left side.

The correct use of currency symbols in e-commerce is essential for clarity, trust, compliance, and overall user satisfaction. It helps prevent confusion, improve the shopping experience, and boost sales.

How to Change Currency Position From Left to Right in Magento 2?

Let’s follow the steps below for that:

Step 1: Let’s assume that you have created a simple module. After you need to create di.xml file at app/code/Vendor/Module/etc directory and paste the below code:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Directory\Model\Currency">
        <plugin name="currency_position_update"
            type="Vendor\Module\Plugin\ChangeCurrencyPosition"/>
    </type>
</config>

Here I have created a plugin for the core file where the position of the currency symbol is being organized.

Step 2: Now you need to create ChangeCurrencyPosition.php file at app/code/Vendor/Module/Plugin as an implementation of the plugin.

<?php
namespace Vendor\Module\Plugin;

class ChangeCurrencyPosition
{
    /**
     * Change currency position
     *
     * @param \Magento\Directory\Model\Currency $subject
     * @param float $price
     * @param array $options
     * @return array|array[]
     */
    public function beforeFormatTxt(
        \Magento\Directory\Model\Currency $subject,
        $price,
        $options = []
    ) {
        $options['position'] = 16; // 16 is for Right position, 8 is for Standard position and 32 is for Left position
        return [$price,$options];
    }
}

Here we have used the before Plugin because we need to change the argument of the original method and it will be executed before calling the original method. You can learn more about the plugin here.

Now, you just need to clear the cache and check it. You will see that the currency position is displayed on the right side throughout the entire website.

You may also like this:

I hope this article is easy to understand regarding how to change the currency position in Magento 2. If I overlooked any details or if you have additional information to contribute, please don’t hesitate to leave a comment below. I’ll be sure to address any queries and provide the necessary solutions.

5/5 - (1 vote)