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

13 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
  4. Thanks you so much and you also tell us to how to change price in detail page also...

    ReplyDelete
  5. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info!
    Magento course in chennai

    ReplyDelete
  6. Marvelous and fascinating article. Incredible things you've generally imparted to us. Much obliged. Simply keep making this kind out of the post.
    custom magento development

    ReplyDelete
  7. Magento has come a long way since 2007 - the year of its initial release. Magento has proven to be the best eCommerce Shopping Cart and there's quite a few reasons for such. plakatų dizainas

    ReplyDelete
  8. hello
    i have changed
    . to ,
    , to
    in the file: vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml (im using english), but the number still like this in the catalog page: 5,900 .and when i open the product page i get the default format like this : 5,900.00
    ps: i have changed also the other files as shown)

    ReplyDelete
  9. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Magento webshop laten bouwen

    ReplyDelete
  10. It will not cost you much more if you need Magento webshop laten bouwen from a well-recognized webshop.

    ReplyDelete
  11. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... magento data entry

    ReplyDelete
  12. IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    JavaScript Online Training in India

    JavaScript Training in India

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete