☰
app/code/[Vendor]/[Module]/etc/frontend/di.xm
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Directory\Model\Currency" type="[Vendor]\[Module]\Position\Model\Currency" />
</config>
app/code/[Vendor]/[Module]/etc/frontend/events.xml
<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]\Observer\ChangeCurrencyPosition" />
</event>
</config>
app/code/[Vendor]/[Module]/Model/Currency.php
<?php
namespace [Vendor]\[Module]\Model;
class Currency extends \Magento\Directory\Model\Currency
{
public function formatTxt($price, $options = [])
{
if (!is_numeric($price)) {
$price = $this->_localeFormat->getNumber($price);
}
$price = sprintf("%F", $price);
return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options);
}
}app/code/[Vendor]/[Module]/Observer/ChangeCurrencyPosition.php
<?php
namespace [Vendor]\[Module]\Observer;
use Magento\Framework\Event\ObserverInterface;
class ChangeCurrencyPosition implements ObserverInterface
{
public function execute(\Magento\Framework\Event\Observer $observer)
{
$currencyOptions = $observer->getEvent()->getCurrencyOptions();
<span class="hljs-comment">// $currencyOptions->setData('position', \Magento\Framework\Currency::LEFT);
$currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);
return $this;
}
}