10

As I said in the title, I want to remove precision from price ( .00 )

I did these :

  1. In app/code/core/Mage/Directory/Model/Currency.php

in

public function format()

I changed

 return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);

to

 return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
  1. In /app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php

in

public function getEscapedValue()

I changed

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

to

 return number_format($value, 0, null, '');
  1. In js/varien/js.js

I changed

var precision = isNaN(format.precision = Math.abs(format.precision)) ? 2 : format.precision;
var requiredPrecision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;

to

var precision = 0;
var requiredPrecision = 0;
  1. And in app/code/core/Mage/Core/Model/Store.php

I changed

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

to

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

Then I cleared the cache, and reindexed Magento (which is i version1.9), But the precision didn't remove, Am I missing something? what should I do?

  • Always override core classes – Beto Castillo Jan 17 '17 at 6:28
13

You could take a look at http://www.magentocommerce.com/magento-connect/et-currency-manager.html I have never used it but I can see you can manage the decimal places and more

"Who needs cents anyway? You can display price without zero cents. Example: display 49 instead of 49.00, but leave 49.99 unchanged."

Plus it free :-)

  • will it change the invoice value? – M.Elwan Apr 19 '17 at 10:22
4

Old question, but does not really have a programmatic correct answer.

$_product is your product object model.

$price = ($_product->getFinalPrice() != 0) ? $_product->getFinalPrice()
            : $_product->getPrice();
        if ($round) {
            $store = Mage::app()->getStore(null);
            $currency = $store->getCurrentCurrency();
            return $currency->formatPrecision($price, 0, array(), true, false);
        }
        return Mage::helper('core')->currencyByStore($price)

protected by Rajeev K Tomy Apr 17 '15 at 7:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.