Tutorialsplane

Magento 2 Format Price


Magento 2 Format Price – We can use number_format function to format price in Magento2 upto decimal 2,3 digits. Here in this tutorial we are going to explain how to format price in Magento 2.


Magento 2 Format Price Example

You can use number_format function to format the price in Magento 2. Here is an example of Number formatting in Magento 2.

Magento 2 Format Price to 2, 3 decimal places Example:

//upto two decimal places
echo number_format($product->getPrice(), '2', '.', ',');
//upto three decimal places
echo number_format($product->getPrice(), '3', '.', ',')