PauseBreak Media 2008.10.28 / For the love of Media

We love all things from website design, architecture, fashion, photography, nature, not some much politics yet we do, tv games and lots more!



WordPress Frame Works & Themes wordpress-frameworks

Our Services PauseBreak Media - Our Services

Magento eCommerce – Price Rounding off Issues

  • Situation: Magento not rounding off product prices correctly
  • Magento Version:

I have had to get my hands pretty dirty lately with Magento eCommerce as we have been moving thick and fast into the eCommerce development site of the industry. While building a theme for one of our clients we started noticing issues with prices that include VAT / TAX which was not being rounded of correctly.

For instance we would add the product, give it a price of R490.00 only to find it being displayed as R489.99…mmm, this got my brain working in over drive and after a few a searches “luckily” I came across this thread on the Magento site – http://www.magentocommerce.com/boards/viewthread/247201/ – thanks guys as I was getting pretty desperate at this time of the evening. I find that these types of issues can take you days to find the answers to a rather simple work around.

I also found this good read and explanation for this situation – http://www.edmondscommerce.co.uk/magento/magento-rounding-errors-1-6-0/ 

What you need to do is find the following file – core/Mage/Tax/Helpers/Data.php and search for the following lines:

  • $price = $this->_calculatePrice($price, $includingPercent, false);
  • $price = $this->_calculatePrice($price, $percent, true);

And replace ALL INSTANCES with the following below:

  • $price = $this->_calculatePrice($price, $includingPercent, true); 
  • $price = $this->_calculatePrice($price, $percent, false);

I do suggest that once done you Flush The Magento Cache and do a quick Re-index in the Index Management section under System. This pretty much helped me in my situation.

Please note that this helped me in my situation and I do strongly suggest that you always keep a backup of your database just incase something goes wrong.