Search code examples
magento2

Magento 2 Currency symbol is not showing


I have 2 stores English and Arabic. Default Store is Arabic and default currency is SAR. Currency symbol is showing fine on English Store but not showing anywhere on Arabic store. It only showing price like this 44 on product listing page and on single product page.


Solution

  • I fixed it. Posting my answer may be it can help someone.

    edit this file.

    vendor\magento\zendframework1\library\Zend\Locale\Data\ar_SA.xml
    

    and remove following code.

    <numbers>
    <currencyFormats numberSystem="latn">
    <currencyFormatLength>
    <currencyFormat type="standard">
    <pattern>¤#0.00</pattern>
    </currencyFormat>
    </currencyFormatLength>
    </currencyFormats>
    </numbers>
    

    UPDATED ANSWER ========

    I got better solution instead editing core file you can do it with observer.

    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>
    

    and observer File.

    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;
        }
    }
    

    Need to change the 'position' to RIGHT.