Magento prices to display and round to the third (3rd) decimal point you need to override these files:
lib/Zend/Currency.php
Change:
protected $_options = array(
'position' => self::STANDARD,
'script' => null,
'format' => null,
'display' => self::NO_SYMBOL,
'precision' => 2,
'name' => null,
'currency' => null,
'symbol' => null,
'locale' => null,
'value' => 0,
'service' => null,
'tag' => 'Zend_Locale'
);
To
protected $_options = array(
'position' => self::STANDARD,
'script' => null,
'format' => null,
'display' => self::NO_SYMBOL,
'precision' => 3,
'name' => null,
'currency' => null,
'symbol' => null,
'locale' => null,
'value' => 0,
'service' => null,
'tag' => 'Zend_Locale'
);
Override file from core to local and change at the bottom
app/code/local/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php
Change:
public function getPriceValue($value, $type)
{
if ($type == 'percent') {
return number_format($value, 2, null, '');
} elseif ($type == 'fixed') {
return number_format($value, 2, null, '');
}
}
To:
public function getPriceValue($value, $type)
{
if ($type == 'percent') {
return number_format($value, 3, null, '');
} elseif ($type == 'fixed') {
return number_format($value, 3, null, '');
}
}
app/code/local/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php
Change:
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, '');
}
app/code/local/Mage/Core/Model/Store.php
Change:
public function roundPrice($price)
{
return round($price, 2);
}
To:
public function roundPrice($price,$roundTo=3)
{
return round($price, $roundTo);
}
To show in frontend:
app/code/local/Mage/Directory/Model/Currency.php
Change:
public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)
{
return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
}
To:
public function format($price, $options = array(), $includeContainer = true, $addBrackets = false)
{
return $this->formatPrecision($price, 3, $options, $includeContainer, $addBrackets);
}
For Tire Price field in backend:
app/design/adminhtml/default/default/template/catalog/product/edit/price/tier.phtml
Change:
<?php echo sprintf('%.2f', $_item['price']) ?>
To:
<?php echo sprintf('%.3f', $_item['price']) ?>
For Sales/orders order view in backend:
app/code/local/Mage/Adminhtml/Block/Sales/Items/Abstract.php
Change:
public function displayPrices($basePrice, $price, $strong = false, $separator = '<br />')
{
return $this->displayRoundedPrices($basePrice, $price, 2, $strong, $separator);
}
public function displayRoundedPrices($basePrice, $price, $precision=2, $strong = false, $separator = '<br />')
{
if ($this->getOrder()->isCurrencyDifferent()) {
$res = '';
$res.= $this->getOrder()->formatBasePricePrecision($basePrice, $precision);
$res.= $separator;
$res.= $this->getOrder()->formatPricePrecision($price, $precision, true);
}
else {
$res = $this->getOrder()->formatPricePrecision($price, $precision);
if ($strong) {
$res = '<strong>'.$res.'</strong>';
}
}
return $res;
}
To:
public function displayPrices($basePrice, $price, $strong = false, $separator = '<br />')
{
return $this->displayRoundedPrices($basePrice, $price, 3, $strong, $separator);
}
public function displayRoundedPrices($basePrice, $price, $precision, $strong = false, $separator = '<br />')
{
if ($this->getOrder()->isCurrencyDifferent()) {
$res = '';
$res.= $this->getOrder()->formatBasePricePrecision($basePrice, $precision);
$res.= $separator;
$res.= $this->getOrder()->formatPricePrecision($price, $precision, true);
}
else {
$res = $this->getOrder()->formatPricePrecision($price, $precision);
if ($strong) {
$res = '<strong>'.$res.'</strong>';
}
}
return $res;
}
app/code/local/Mage/Sales/Model/Order.php
Change:
public function formatPrice($price, $addBrackets = false)
{
return $this->formatPricePrecision($price, 2, $addBrackets);
}
To:
public function formatPrice($price, $addBrackets = false)
{
return $this->formatPricePrecision($price, 3, $addBrackets);
}
Note:If you find better solution please Notify me but this worked for me
3 Comments
Bhautik Patel · November 8, 2016 at 5:33 pm
thnk you for help me……if you have solution for magento 2 then help me
Vladimir · October 22, 2018 at 6:49 pm
Hi,
I have a better solution for change 3rd decimal. If you want the best solution contact me…
Vladimir · October 22, 2018 at 6:49 pm
Email: vlada972010@gmai.com