How to change price format on Magento 2

By default of Magento 2, price format is a little strange for some currencies so we need to change it. Here's the way to change price format.


Here's the example for the case of Vietnamese dong.
Default displayed format was 100.000,00. Then I changed it into 100,000 (separated by comma without decimal point).

# vendor/magento/zendframework1/library/Zend/Locale/Data/vi.xml
<symbols numbersystem="latn">
 <decimal>.</decimal>
 <group>,</group>
</symbols>
# vendor/magento/framework/Pricing/PriceCurrencyInterface.php
const DEFAULT_PRECISION = 0;
# vendor/magento/module-directory/Model/Currency.php
return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
# vendor/magento/module-sales/Model/Order.php
public function formatPrice($price, $addBrackets = false)
{
    return $this->formatPricePrecision($price, 0, $addBrackets);
}
If you liked this article

Let's subscribe the updates of Scuti!
Share on Google Plus

About Tomohide Kakeya

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

3 Comments:

  1. Thanks for share.
    But in Admin Order not effected!

    ReplyDelete
  2. Thank you.
    But product detail page is still have 2 decimal points and backend does not changes.

    ReplyDelete
  3. thank you
    could you please complete this and show how to change in products details page and admin panel and admin invoice , it is been a year now!

    ReplyDelete