Monday, August 19, 2013

How to remove price decimal in magento?

 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






Method 2:

   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)

Ther is magento extension which allows:
  •     Specify number of decimal digits. For price rounding Magento internal algorithm is used. Example: instead of 49.99 you can display 50 or 49.9900.
  •     Display prices without zero decimals. Example: display 49 instead of 49.00, but 49.99 remains unchanged.
  •     Replace zero decimals with suffix. Example: display 49,- instead of 49.00 or 49, but 49.99 remains unchanged.
  •     Specify position of currency symbol: before the price or after. Example: $ 49.99 or 49.99 $
  •     Specify what to use as currency symbol. Example: nothing, use currency code (EUR, USD), use currency symbol (€, $), use currency name (Euro, US Dollar)
  •     Change currency symbol to your own (text only). Example: display Money instead of $
  •     Change zero price to your own text. Example: FREE instead of 0.00
  •     Use separate settings for every store view
  •     Use separate settings for every currency
  •     Enable and disable extension for frontend and admin panel separately
  •     Disable price rounding on checkout page
  •     Enable price rounding on product input page

By PHP with 2 comments

2 comments:

This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.
magento development company in bangalore 

NIce tutorial.Thanks for posting. here is more Magento beginner Tutorial

Post a Comment

    • Popular
    • Categories
    • Archives