0

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

Lovely Setia
  • 427
  • 4
  • 17

1 Answers1

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