I am using magento-2.2.7. In email template, price subtotal and grandtotal is showing like that 0.5000000000045 .How to change this price in proper format. Please help me to solve it. I want to share screenshot as follow : https://paste.pics/67A5H
Asked
Active
Viewed 487 times
1 Answers
0
You can try this code
protected $priceHelper;
public function __construct(
\Magento\Framework\Pricing\Helper\Data $priceHelper
) {
$this->priceHelper = $priceHelper;
}
public function getFormattedPrice($price)
{
return $this->priceHelper->currency($price, true, false);
}
Using Object Manager [Not Recommended way]
<?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);
?>
Hope It helps.
Mohit Rane
- 1,955
- 1
- 13
- 47
Items Totalis coming, you can solve this issue in no time. – Mohit Rane Aug 05 '19 at 05:50totals.phpfile and call that method in phtml file – Mohit Rane Aug 05 '19 at 05:55