Magento 1.9.2: 5-cents Price Rounding

Today I am working on a Magento site for a Switzerland client which requires the implementation of Rappen Rounding, a 5-cents rounding for the total price for every transaction.

I actually found an extension on GitHub for that, but it was not compatible with my Magento install. I am not sure if it is not compatible with Magento 1.9.2 or conflicting with any other extensions, it just didn’t work.

After digging into Magento core codes, I found that there is a simple workaround for this functionality, though we have to override Magento’s core. Please be advised that this is not the best practice, it is just a simple workaround. If you want a better functionality and compatibility with future Magento updates, you’d better build a custom module / extension for that.

Here’s what I did as a workaround:

  1. Override Magento’s core by copying
    app/code/core/Mage/Core/Model/store.php
    to
    app/code/local/Mage/Core/Model/store.php 
  2. Edit the new copied file on the
    function roundPrice($price){} 
  3. Replace the line
    return round ($ price, 2);
    with
    return round($price * 2, 1)/2; 
  4. Save
  5. Flush Magento Cache, and it’s done!

Let me know if it helps!

2 thoughts on “Magento 1.9.2: 5-cents Price Rounding

  1. Thank you! This was exactly what I had to do for a Swiss online shop that I’m developing for in my job. The client will be happy that you saved me so much time – because he pays per hour. You saved me so many headaches because I’m not yet a Magento expert.

Leave a Reply to HappyDev Cancel reply