Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Remove Decimal From Magento-1 Prices?

Tags:

php

xml

magento

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:

       <currencyFormats>
            <currencyFormatLength>
                <currencyFormat>
                    <pattern>#,##0.00 ¤</pattern>
                </currencyFormat>
            </currencyFormatLength>
        </currencyFormats>

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:

<currencyFormats>
            <currencyFormatLength>
                <currencyFormat>
                    <pattern>#,##0 ¤</pattern>
                </currencyFormat>
            </currencyFormatLength>
        </currencyFormats>

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.


update 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..

like image 736
rramiii Avatar asked Dec 04 '14 07:12

rramiii


1 Answers

All answers here involve changing the core files. This is NOT what anyone should do. Either you develop a module and make those changes or you leave the core files like that and change the prices with str_replace.

So go into theme/template/catalog/product/price.phtml and (depending on configuration) around line 209 change this:

$_coreHelper->formatPrice($_price, true)

into

$without_decimals = $_coreHelper->formatPrice($_price, true); echo str_replace(".00", "", $without_decimals); 

This removes .00 from the price. The good thing is that the prices with other decimals are kept. If you don't want this you can remove everything after the dot and round the number up with round() function.

Depending on configuration other prices might need the change (if you show prices without taxes etc.)

like image 59
Claudiu Creanga Avatar answered Oct 12 '22 18:10

Claudiu Creanga