Sunday 16 October 2011

How to remove decimal price in magento

Hello Everyone,

                 Today I’m going to tell you how to remove decimal price in magento.In simple words, This tutorial will tell to change the price from Rs. 121.00 to Rs . 121 for example.
                For this, you need to edit code/core/Mage/Directory/Model/Currency.php


  • Open  code/core/Mage/Directory/Model/Currency.php
  •  Find the following :-
 public function format($price$options=array(), $includeContainer = true, $addBrackets = false)
    {
        return $this->formatPrecision($price, 2, $options$includeContainer, $addBrackets);
    }


on line no 194
change this code to:-

 public function format($price$options=array(), $includeContainer = true, $addBrackets = false)
    {
        return $this->formatPrecision($price, 0, $options$includeContainer, $addBrackets);
    }

0 - Denotes the precision point for price..

But wait, you are still not done. The most important thing is still left.
- Clear the Cache.
- Go to System –> Cache Management
- Refreh Cache.
- If you have not enabled the Cache OR if it didn’t work even after refreshing the cache, then
- delete the cache folder present inside var (var/cache)


You can also refer to the video showing how it actually works


For any magento customization contact :
Company : Parsys Media
Mumbai Office :
Mobile No : +91-8123481528(Ashish Khadpe)





29 comments:

  1. Thanks! However, does this also remove the decimal from the shopping cart? I need the decimal in the shopping cart due to taxes. This needs to apply on the front & back end.

    ReplyDelete
  2. Modgirl
    Then you have to make changes in files like view,new,list.phtml
    Which is against the concept of CMS

    ReplyDelete
  3. I followed the procedure. in most products the decimals are disappierd. But with some products the decimals are still there. If products have customer options the decimals stay. I think the prices of the options are still with decimals?
    I've gone through the whole procedure

    ReplyDelete
  4. Hey Bruno
    We are not changing the price of products just while displaying we are trimming the floating numbers present in the price so floating numbers are still associated with products. If you can provide me the link where you are still getting decimal we can suggest you some solution.

    ReplyDelete
  5. Hi Magento Coders,

    I am facing the same issue, decimals are still there if product has product option.

    ReplyDelete
  6. Can you please help us.

    Thanks

    ReplyDelete
  7. Hi, I am using Community 1.6.1.0 and have simple products with custom options/prices. Prices need to be displayed in JPY Yen. The above solution appears to work on simple products with no options, but the products with options still display the .00 when the option is chosen. Ironically the drop down for the option displays the additional cost of the option without the decimels, but the main price with the option selected still shows the decimels. Could this be in a js file? I'm lost... Thanks in advance.

    ReplyDelete
  8. This comment has been removed by a blog administrator.

    ReplyDelete
  9. Is it more difficult or easier than change locale setting in http://xme.im/format-magento-currency-or-number-base-on-locale
    Is there any extension can do this?

    ReplyDelete
  10. Can you help me remove decimals in magento go version? info@babyshop.cl

    ReplyDelete
  11. Hi Magento Coders,

    I have Removed it from my website RS 2600.00 to RS 2600 Successfully thank you so much for shareing great idea here...

    ReplyDelete
  12. Hi Magento Coders,

    When i add custom option in my product than Price get .00

    How i can solve this problem... please help me

    ReplyDelete
    Replies
    1. HI Chhatrapal, I am having the same problem... Were you able to figure it out?

      Delete
    2. you need to also update 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;

      Delete
  13. Hi Magento Codes

    How can edit RS0.0 to Rs 0.0?

    How i can solve this problem...Please help me.

    ReplyDelete
  14. i am getting four decimal when i minify my js and css ...all setting for 2 ,can you help me?

    ReplyDelete
  15. don't work with magento 1.7.0.2

    ReplyDelete
  16. Thank you so much, very helpful

    ReplyDelete
  17. For people in trouble with this, I found what I guess it's a better solution since it doesn't touch Magento core source:
    http://stackoverflow.com/questions/20900966/magento-price-formatting-2-or-3-decimal-places

    ReplyDelete
  18. Hi I want to change weight decimal precision in admin catalog/product in general tab.

    see the link.

    http://dev-demo.info/weight.jpg
    please suggest
    thanks

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. It has changed only frontend, but not the backend .Please let me know , how can I change to admin also.

    ReplyDelete
  21. Great Read! I am impressed on how you make your article easy to understand. I'll come back for more :D

    For more tutorial and tips about web design and web development you can follow me here -> http://alwaysopencommerce.com/http://alwaysopencommerce.com/

    ReplyDelete
  22. Price calculation total problem
    Ex:
    Grand Total Excl. Tax $34.95
    Tax $4.54
    Grand Total Incl. Tax $39.49
    --------------
    Subtotal $34.95
    ------------
    changed the price to 0 but Subtotal value not correctly added
    Ex:
    Grand Total Excl. Tax $35
    Tax $5
    -------------
    Grand Total Incl. Tax $39
    --------------

    Please Help to solve

    ReplyDelete
  23. schick quattro titanium - stainless steel & chrome - TiNanium Arts
    Stainless steel & chrome are titanium dioxide sunscreen solid steel. titanium 4000 We are chrome tungsten titanium based titanium dioxide and have seen stiletto titanium hammer excellent performance in the wet bar, wet bar, and powder.

    ReplyDelete