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

1 Answer 1


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]

    $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.

  • on which file @Mohit Rane ? Jul 25, 2019 at 5:24
  • you can write this code in your block and call the function where you want to use
    – Mohit Rane
    Jul 25, 2019 at 5:30
  • I want to use in order email template. Jul 25, 2019 at 5:30
  • which block module_sales block or module_email block ?? Jul 25, 2019 at 5:33
  • is this your custom email template and are you using any module?
    – Mohit Rane
    Jul 25, 2019 at 5:35

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.