rramiii rramiii - 1 year ago 105
PHP Question

How To Remove Decimal From Magento-1 Prices?

all I found in my search is a programming solution for this.
I know that we can modify /lib/Zend/Locale/Data/en.xml for english stores.
there was in en.xml this part:

<pattern>#,##0.00 ¤</pattern>

And the price was displaying in this format: 1,321.54
now to remove the decimal part from price I think the only thing I have to do is change en.xml to be like the following:

<pattern>#,##0 ¤</pattern>

The problem is after this change the prices are show as desired (1,132 Format) but without currency symbol ($).
what I'm missing here??
Thanks in advance.

I'm still trying, when pattern node changed to the following

<pattern>¤ #,##0</pattern>

the prices are coming with currency symbol ($ 1,132) but not in desired position O_O, the requirement is to have currency symbol on the right side no left :( SO..

Answer Source

In order to change price precision in magento you would need to overwrite some core files.

In the example below we are changing precision to 0.

1) Overwrite lib/Zend/Currency.php and change precision around line:

 69     protected $_options = array(
 70         'position'  => self::STANDARD,
 71         'script'    => null,
 72         'format'    => null,
 73         'display'   => self::NO_SYMBOL,
 74         'precision' => 0,    /*CHANGE*/
 75         'name'      => null,
 76         'currency'  => null,
 77         'symbol'    => null,
 78         'locale'    => null,
 79         'value'     => 0,
 80         'service'   => null,
 81         'tag'       => 'Zend_Locale'
 82     );

2) overwrite app/code/core/Mage/Core/Model/Store.php and change roundPrice function:

public function roundPrice($price)
    return round($price, 4);

3) overwrite app/code/core/Mage/Directory/Model/Currency.php and change format function:

public function format($price,
                            $includeContainer = true,
                            $addBrackets = false)
  return $this->formatPrecision( $price,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download