I want to show currency symbol and amount in separate html elements such as: BD18.00

into this:


is it achievable?

| improve this question | | | | |
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterfa‌​ce'); 
$currencyCode = $storeManager->getStore()->getCurrentCurrencyCode(); 
$currency = $objectManager->create('Magento\Directory\Model\CurrencyFact‌​ory')->create()->loa‌​d($currencyCode); 

echo "<span>{$currency->getCurrencySymbol()}</span><span>{$product->getPrice()}</span>"; 
| improve this answer | | | | |
  • I can show in this way, but I want it to behave like default price like changing custom option, will change price as well. – Manish Joy Nov 20 '17 at 5:32

You can change the price format by change theme files.


Just replace or comment

<?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>

and add the following snippet

<span class="av-new-price"><?= $block->getDisplayCurrencyCode() ?></span>
    <span class="av-amount"><?php echo number_format($block->getDisplayValue(),2) ?></span>

If this file not in your directory just overrides.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.