Showing posts with label magento Price. Show all posts
Showing posts with label magento Price. Show all posts

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

Thursday, May 16, 2013

Magento - Get tier price with mini price display / Tier Lowest Price Display

Magento get tier price with minimum price display


<?php
$product_tier_prices = $this->getTierPrices($_product);
if(count($product_tier_prices) > 0){
$product_tier_prices = (object)$product_tier_prices;
$product_price = array();
foreach($product_tier_prices as $key=>$value){
$value = (object)$value;
$product_price[] = $value->price;
}
echo 'As low as: '.Mage::helper('core')->currency(min($product_price),true,false);
}
?>


  Method 2

 

 

A few weeks ago we were scratching our heads in confusion on how to get the lowest tier-price from magento. If you take a look at your catalog>product>view>tierprices.phtml you will see why – why does such a complicated section of code even exist?
Anyway after a few failed attempts we were contacted this morning by Christiaan who asked us this question a few weeks ago on the magento forums. We took this as a challenge and set to work this very morning sorting it out.
After a few black coffees we finally figured it out…or at least got rid of the rubbish that was concealing it. We now have a little method to bring back the lowest tier price on a magento product view page!
Here is how you do it:
1. Create a file in your product>view folder called getlowest.phtml
Copy & paste the following into it:
<?php
/**
* @E-Commercewebdesign.co.uk
*/
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);

$_weeeTaxAmount = Mage::helper('weee')->getAmountForDisplay($_product);
if (Mage::helper('weee')->typeOfDisplay($_product, array(1,2,4))) {
$_weeeTaxAttributes = Mage::helper('weee')->getProductWeeeAttributesForDisplay($_product);
}

?>
<?php if (count($_tierPrices) > 0): ?>
<?php if ($this->getInGrouped()): ?>
<?php $_tierPrices = $this->getTierPrices($_product); ?>
<?php endif; ?>
<?php Mage::helper('weee')->processTierPrices($_product, $_tierPrices); ?>
<?php $i = 0; ?>
<?php $_tierPrices = array_reverse($_tierPrices); ?>
<?php foreach ($_tierPrices as $_price): ?>
<?php if($i==0){ ?>
<p style="font-weight:bold; font-size: 1em;">After tier pricing the lowest price you can have a Cowboy Hat is...
<span style="font-size:150%; text-decoration:underline;">
<?php echo $_price['formated_price']; ?>
</span>
<p>
<?php $i++; ?>
<?php } ?>
<?php endforeach ?>
<?php endif;?>
As you can see you can edit some words above to output whatever you like around this lowest price – could be on top of an image or simply surrounded by text like above.
2. Open your themes catalog.xml and paste in the following code:
<block type="catalog/product_view" name="getlowest" as="getlowest" template="catalog/product/view/getlowest.phtml" />
3. Call this function on your product>view.phtml
<?php echo $this->getChildHtml('getlowest') ?>
There you have it! This code will output the lowest price of your tier prices dynamically – and will also not show anything if tier-prices are not activated for the product.

 

By PHP with 4 comments

Magento - Get Min and Max product price in current category / Display lowest / highest price from current product collection

Display minium / lowest product price from current category in magento. get min price from current product collection. Fine the below code to get min price value.


echo $minPrice=Mage::getSingleton('catalog/layer')
->setCurrentCategory(Mage::registry('current_category'))
->getProductCollection()
->getMinPrice();


Display maximum / Highest product price from current category in magento. get max price from current product collection. Fine the below code to get max price value.

echo $maxPrice=Mage::getSingleton('catalog/layer')
->setCurrentCategory(Mage::registry('current_category'))
->getProductCollection()
->getMaxPrice();

By PHP with No comments

    • Popular
    • Categories
    • Archives