How to edit the way the currency displays

Hi Guys, Sorry for all the questions but Magento2 seems a lot different to the previous version. I have changed the currency to IDR on my site. The symbol works fine. However, the decimal places do not.

In Indonesian currency the numbers should be as follows:
IDR 130,000 the equivalent of $10
IDR 1,300,000 the equivalent of $100
IDR 13,000,000 the equivalent of $1,000
Where can i change the settings so they follow the above number of decimal places and commas instead of fullstops as they do on the following site? http://www.bobobobo.com/page/men/whats-new?brand=10-deep--adidas-originals--after-midnight-nyc--billionaire-boys-club--black-scale--bluesville--butter-goods--f-a-m-t--funday-ca--gravity-element--have-a-good-time--hay-united--huf--i-love-ugly--jan-sober--kept-apparel--life-behind-bars--lo-fi--non-conformist--pmp-denim--polar-skate-co--ripndip--staple--stussy--taylor-fine-goods--thrasher--timex--undefeated--youth-machine&v=30&sort=new

thanks Jim

9 answers

Profile photo of Frank 1460.00 $tone January 12, 2017
Public

Hi James,
That is the working rule of Magento 2 core. In case you wish to customize that, you can follow the guide mentioned in this post:
http://magento.stackexchange.com/questions/115636/how-to-change-currency-format-in-magento-2/115666
Please note: for the file vendor/magento/zendframework1/library/Zend/Locale/Data/vi.xml, you should edit the file en.xml instead. 

# 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);
}

Regards,
Frank

#1
Profile photo of James Weston 2860.00 $tone January 12, 2017
Public

Thanks Frank, That worked great. I posted a message to the person who came up with the fix asking if there was any other lines of code to change so that it also works in the back end and the shopping cart as well.
Many thanks Jim

#2
Profile photo of James Weston 2860.00 $tone January 13, 2017
Public

Hi Frank, sorry I have no idea what is going on with this template. Last night the currency was working fine and I marked this as solved. 
Today I added a new product and it has gone back to the way it was before I made the changes 🙁
Any ideas?
 
Jim

#3
Profile photo of Frank 1460.00 $tone January 13, 2017
Public

Hi Jim,
I checked the product “Coldstream Hills Reserve Pinot Noir” that you’ve added and see the currency format 1,700,000. (Ref: http://prntscr.com/dv1dvo). 
May I know the product associated with the issue you mentioned? I will check further.
Regard,
Frank

#4
Profile photo of James Weston 2860.00 $tone January 13, 2017
Public

Hi Frank, thanks. I am not sure what is happening with the caching on my desktop computer. Now it is all showing correctly. Before it was showing wrongly on chrome and safari.
 
Jim

#5
Profile photo of James Weston 2860.00 $tone January 14, 2017
Public

Hi Frank, when I click on the product on any of my devices it has the .00 still at the end in product view http://prntscr.com/dve6vk
In category view it is fine http://prntscr.com/dve7fc
Jim

#6
Profile photo of Frank 1460.00 $tone January 14, 2017
Public

Hi Jim,
To change the product price format, you can open the file “price-utils.js” at “vendor\magento\module-catalog\view\base\web\js” and add the line:
“var precision = 0, ” (see ref: http://prntscr.com/dvfg68)
above the line:
“var globalPriceFormat = {”
Then run the command line:
rm -R var/*
rm -R pub/static/*
php -f bin/magento setup:static-content:deploy
Please note this tweak change the Magento 2 core which is a drawback when you update Magento version later on. Within scope of our standard support, I am afraid we can help you with bug fixes only. Customization should be handled at your end. 
Regard,
Frank

#7
Profile photo of James Weston 2860.00 $tone January 14, 2017
Public

Thanks Frank will give that a go. Can you point me to a tutorial or post that explains to me where to do the following.
Then run the command line:
rm -R var/*
rm -R pub/static/*
php -f bin/magento setup:static-content:deploy
 

#8

Please login or Register to Submit Answer

Written By

Comments