1

How can I change currency position?

I referred this, But, I have not it app\code\Vendor\Extension\etc\ What should I do?

  • vendor_extension refers to your extension. This means you need to create a new extension where vendor is the module name space or package name and extension refers to module name. – Priyank Sep 27 '18 at 11:51
  • admin or front ? – Aditya Shah Sep 27 '18 at 11:54
2

There is an easy way to change the currency position in the Locale (language) you want in Magento 2 admin


  1. Go from your root folder to /lib/Zend/Locale/Data

  2. Find the lenguage file. In my case es.xml

  3. Look for <currencyFormat>

A line just below you will find the <pattern>

Change the side of the weird symbol and leave it like this:

Before

<currencyformatlength>
   <currencyformat>
    <pattern>¤ #,##0.00</pattern>
  </currencyformat>
</currencyformatlength>

After

<currencyformatlength>
   <currencyformat>
    <pattern>#,##0.00 ¤</pattern>
  </currencyformat>
</currencyformatlength>
  • I finded en.xml and I changed it like You but it doesn't work – wluczykuj Sep 27 '18 at 12:15
  • are you checking on admin side ? – Aditya Shah Sep 27 '18 at 12:16
  • Sorry,I do not understand a bit. I changed to <pattern>#,##0.00 ¤</pattern> and I cleared cache on admin panel. – wluczykuj Sep 27 '18 at 12:20
  • are you checking currency symbol at front side or admin side ? – Aditya Shah Sep 27 '18 at 12:21
  • at front side and admin – wluczykuj Sep 27 '18 at 12:22
1

How good is this,

Create events.xml file inside your folder.

app\code\Vendor\Extension\etc\events.xml

Add below code in events.xml

<?xml version="1.0"?>    
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="currency_display_options_forming">
        <observer name="vendor_extension_change_currency_position" instance="Vendor\Extension\Model\Observer\Changecurrencyposition" />
    </event>
</config>

Now you need to create observer file inside the extension folder at path app\code\Vendor\Extension\Model\Observer\Changecurrencyposition.php

<?php        
namespace Vendor\Extension\Model\Observer;    
use Magento\Framework\Event\ObserverInterface;    
class Changecurrencyposition implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {    
        $currencyOptions = $observer->getEvent()->getCurrencyOptions();    
        $currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);  
        return $this;
    }    
}

Run the following command and you are done.

php bin/magento setup:upgrade
0

You must have to create a custom extension.

Also, this module should have:

  1. app/code/{Vendor}/{Modulename}/etc/module.xml.
  2. app/code/{Vendor}/{Modulename}/composer.json
  3. . app/code/{Vendor}/{Modulename}/registration.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.