Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento How do I set the product price to 4 decimal places

Tags:

magento

For a UK or Europe store we have to show inc VAT prices. i.e. a product selling for £15.95 on the store front would be stored in the admin as £13.5744 - so that when the VAT(17.5%) is added it will make £15.95

Unfortunately Mag seems to only store the price to 2dp. Even is you enter 13.5744 in the admin for the price - you get 13.57 on refresh.

Is it possible to store admin product price in 4dp and at frontend we show on 2dp?.

Cheers,

like image 710
magento2new Avatar asked Aug 08 '11 09:08

magento2new


People also ask

How do I get special prices in magento2?

From Magento 2 settings, you can get the special price configuration in the Advanced Settings of the individual product. Then you only need to enter the number for the discounted price and the active time to apply. As you configure, the special price is applied immediately.


2 Answers

From my understanding, you would need to take a close look at lib/Zend/Currency.php

Further investigating you would need to adjust the precision to 4 instead of 2:

http://framework.zend.com/manual/1.12/en/zend.currency.options.html
(edit: updated link to latest available version)

This thread has more details on implementing such as well, it looks as though Magento also does some price formatting else where also:

http://www.magentocommerce.com/boards/viewthread/16337/

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php

return number_format($value, 4, null, '');

I know its not a definitive answer but hopefully leads you in the right direction.

like image 173
B00MER Avatar answered Sep 28 '22 04:09

B00MER


There is also the function roundPrice() that might have been updated as well. This can be found in app/code/core/Mage/Core/Model/Store.php

Incase you are still stuck.

like image 39
Herbert Avatar answered Sep 28 '22 05:09

Herbert