To get the currency code and symbol, you need to write the code in .php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
protected $_storeManager; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, array $data = [] ) { parent::__construct($context, $data); $this->_storeManager = $storeManager; } public function getCurrencyData(){ $currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode(); // give the currency code $currencyRate = $this->_storeManager->getStore()->getCurrentCurrencyRate(); // give the currency rate } |
To get Currency Symbol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
protected $_currency; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Model\Currency $currency, array $data = [] ) { parent::__construct($context, $data); $this->_currency = $currency; } public function getCurrencySymbol() { return $this->_currency->getCurrencySymbol(); } |
where to write the code in .php file and another code? which magento file?