Pages

Monday, September 7, 2015

Magento 2: Get Currency Symbol


To get the currency code and symbol, you need to write the code in .php file

<?php

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
}

?>

No comments:

Post a Comment