Tuesday 21 August 2012

Magento - Product Price without decimal points

If you want to remove decimal points from Price ( front-end ) then use following steps :


Step 1:

Change the following file to remove the decimal points:

go to : lib/Zend/Currency.php

In the “toCurrency” function add the following line:

$options['precision'] = 0; around 184 line
above this :

$value    = Zend_Locale_Format::toNumber($value, array('locale'        => $locale,
                                                               'number_format' => $format,
                                                               'precision'     => $options['precision']));
replace to :
$value    = Zend_Locale_Format::toNumber($value, array('locale'        => $locale,
                                                               'number_format' => $format,
                                                               'precision'     => 0));


Step 2:

Change the following price to round the price:

app/code/core/Mage/Core/Model/Store.php

Change in method “roundPrice()” to the round prices in product listing and view pages like this:

return round(ceil($price), 0 );

like this :

public function roundPrice($price)
{
        //return round($price, 0);
        return round(ceil($price), 0 );
}

Please let me know if you have any questions


1 comment:

  1. Thx a lot for his post post. Made my day.

    I would like to ask you. I need to add a class to the standard currency symbol ($) or other depending on the currency that is set as standard.

    I would like it to be outputted something like this:
    < p class="currency"> $ < span class="price" > 90 < / span > < / p >
    I have been looking in the currency.php file but i cannot manage to find where.

    ReplyDelete