1

How to display price currency symbol after the amount on the right side. from: USD333 to: 333USD

  • I hope my answer will solve your issue – Nikunj Vadariya Jun 9 '18 at 11:05
  • Please share your code. – kunj Jun 9 '18 at 11:17
2

You can do it by writing single event observer

Create registration file:

Vendor\Module\registration.php

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_Module',
    __DIR__
);

Create module file:

Vendor\Module\etc\module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="1.0.0"></module>        
</config>

Create event File:

app/code/Vendor/Module/etc/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="change_currency_position" instance="Vendor\Module\Model\Observer\ChangeCurrencyPosition" />
    </event>
</config>

Create observer File:

Write a observer file in app/code/Vendor/Module/Model/Observer with the file name ChangeCurrencyPosition.php

<?php        
namespace Vendor\Module\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 Command:

php bin/magento setup:upgrade

  • It did not work, Magento 2.2.3 and base currency is AED not USD – Ahmad Darwish Jun 9 '18 at 11:11
  • @AhmadDarwish what error you got after doing same? – Nikunj Vadariya Jun 9 '18 at 11:15
  • No errors, nothing changing, where to trace the errors any log? – Ahmad Darwish Jun 9 '18 at 11:17
  • check error in var/log @AhmadDarwish – Nikunj Vadariya Jun 9 '18 at 11:19
  • I can see in exception.log : the Item (Magento\\Catalog\\Model\\Product\\Interceptor) with the same ID \"704\" already exists. at /var/www/html/herara/vendor/magento/framework/Data/Collection.php:404) – Ahmad Darwish Jun 9 '18 at 11:25

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.