Sometimes we want the formatted price in phtml file. But in Magento 1 we could directly wrote using core module file.
So you might think, is it possible in Magento 2?
Yes, it is possible but there are different way to access this.
Magento 2 gives the formatted price in 2 core modules:
If we want the formatted price in checkout page, we can write this code:
$checkouthelper = $this->helper('\Magento\Checkout\Helper\Data'); echo $checkouthelper->formatPrice($_item->getWarrantyCharge());
If we want the formatted price in Sales/Order page, we can write this code:
Now refresh the page and check the formatted price.