- Get link
- Other Apps
The default Magento 2 shows the currency symbol on the left side. However it does not have a feature to change the currency location from left to right.
Programmatic solution to change currency symbol position in Magento 2.
Solution to Change Currency Symbol Position in Magento 2
Create events.xml file at app/code/vendor/Exenstion/etc/frontend
<?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\Exenstion\Observer\ChangeCurrencyPosition"/>
</event>
</config>
<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\Exenstion\Observer\ChangeCurrencyPosition"/>
</event>
</config>
Create ChangeCurrencyPosition.php file at app/code/vendor/Exenstion/Observer
<?php
namespace vendor\Exenstion\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;
}
}
namespace vendor\Exenstion\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;
}
}
Glad to find this. Your site very helpful and this post gives lots of information. Do share more updates.
ReplyDeletePHP course in Chennai
PHP Training Online
PHP course in Coimbatore
You've written an excellent post, and you've shared it with us about Magento Development Services. Your article provided me with some unique and useful knowledge. I appreciate you sharing this text with us.
ReplyDeleteBest Betting Sites in South Africa - JtmHub
ReplyDeleteBetway has been around since 2016 and 광명 출장샵 is one of the best 익산 출장샵 betting sites in South Africa. 포항 출장마사지 They have a great selection of banking options 경주 출장샵 and a huge 포천 출장샵 range of
This comment has been removed by the author.
ReplyDelete