Displaying Prices with the Right Currency Format in Magento 2
Printing a raw number as a price misses the currency symbol, decimal rules and locale formatting. Magento 2’s pricing helper handles all of that for you.
Example
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of Object Manager
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data'); // Instance of Pricing Helper
$price = 1000; //Your Price
$formattedPrice = $priceHelper->currency($price, true, false);
?>
The output respects the current store’s currency and locale, so £1,299.00 in a UK store and $1,299.00 in a US store come from the same code.
Need a second pair of eyes on this? Our team handles Magento development every week. See how we can help.