Magento 2 – How to Get Current Currency and Symbol in PHTML File

currencymagento2template

How can I get current currency and currency symbol in Magento 2 in a template (.phtml file)? Without creating a block

Best Answer

please note that creating this with objectManager, not the best practice

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$currencysymbol = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currency = $currencysymbol->getStore()->getCurrentCurrency();

getCurrentCurrencyCode() Gives the Currency code and not the symbol but you were helpful rest I figured -

<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
    $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface'); 
    $currencyCode = $storeManager->getStore()->getCurrentCurrency(); 
    $currency = $objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($currencyCode); 
    echo $currencySymbol = $currency->getCurrencySymbol(); ?>
Related Topic