Second time now I’ve had the client request that set their Magento prices to display and round to the third (3rd) decimal point. This time I will share with you how I performed this change in Magento (ver. 1.3.2.4).

First I FTP to my lib/Zend/Currency.php file and change the following:


protected $_options = array(
 'position'  => self::STANDARD,
 'script'    => null,
 'format'    => null,
 'display'   => self::NO_SYMBOL,
 'precision' => 2,
 'name'      => null,
 'currency'  => null,
 'symbol'    => null
 );

to


protected $_options = array(
 'position'  => self::STANDARD,
 'script'    => null,
 'format'    => null,
 'display'   => self::NO_SYMBOL,
 'precision' => 3,
 'name'      => null,
 'currency'  => null,
 'symbol'    => null
 );

Please note that if you upgrade Magento this will be overwritten and this change will be required again after upgrade!!!

Second, copy app/code/core/Mage/Core/Model/Store.php to app/code/local/Mage/Core/Model/Store.php. By doing this you protect this file from being overwritten during upgrades. Next change the following code in that file from:


public function roundPrice($price)
 {
 return round($price, 2);
 }

to


public function roundPrice($price,$roundTo=3)
 {
 return round($price, $roundTo);
 }

Lastly, I suggest copying app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php to app/code/local/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php. Then you can change the following code in that file from:


public function getEscapedValue($index=null)
 {
 $value = $this->getValue();

 if (!is_numeric($value)) {
 return null;
 }

 return number_format($value, 2, null, '');
 }

to


public function getEscapedValue($index=null)
 {
 $value = $this->getValue();

 if (!is_numeric($value)) {
 return null;
 }

 return number_format($value, 3, null, '');
 }

Clear your Magento Cache and now you have prices that extend to the third (3rd) decimal point both on the front end and in the admin section of Magento!!!

If you have any suggestions on how to improve this post please feel free to drop me a line!

Leave a Reply