Show custom currency symbol in Magento2

by jafar pinjar   Last Updated August 13, 2019 16:09 PM - source

I used below event

<event name="currency_display_options_forming">
    <observer name="vendor_extension_change_currency_position" instance="Vendor\Module\Observer\ChangeCurrencySymbol" />
</event>

then,

<?php        
namespace Vendor\Module\Observer;    
use Magento\Framework\Event\ObserverInterface;    
class ChangeCurrencySymbol implements ObserverInterface
{
private $logger;
public function __construct(
    \Psr\Log\LoggerInterface $logger
){
    $this->logger = $logger;
}

public function execute(\Magento\Framework\Event\Observer $observer)
{    
    $currencyOptions = $observer->getEvent()->getCurrencyOptions();    

    $this->logger->info('options'.$currencyOptions->getBaseCode());
    $currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);  
    $currencyOptions->setData('base_code', 'USD');  
    return $this;
}    

}

The above code changes the currency symbol position from left to Right.

I am looking for code how can we show custom currency symbol in all the pages.

I used below code, $currencyOptions->setData('base_code', 'USD');

I need to show $ all the places where prices are displaying.

Is that can be achieved? Can anybody help me.



Related Questions


M2.3.1 - Remove currency symbol from price

Updated May 08, 2019 10:09 AM

Change currency Symbol in cart and checkout Magento2

Updated August 13, 2019 11:09 AM

Rupee Symbol error

Updated August 10, 2019 13:09 PM

i want change language according to access point

Updated May 08, 2018 13:09 PM