How to show Tier prices Magento

Do you want to show tier prices in your product list or product view?

The function

The function we need to use is:

Version

I’ve tested my code in a Magento 1.3 version.

Code

You should paste this close to where the main price os printed.

Please notice the formated_price_incl_tax you may change this if you’re using excluding tax.

Tags:

41 Responses to “How to show Tier prices Magento”

  1. Graeme Lawton November 2, 2010 at 12:22 pm #

    When trying this on 1.4.1 on the listings page I get a blank array back even when the product has tiered pricing.

    • quicoto November 2, 2010 at 12:26 pm #

      Hey Graeme,

      Try to print this:

      [code]print_r($this->getTierPrices($_product));[/code]

      Let’s see what it gets πŸ˜‰

      Notice i’m using the formated_price_incl_tax

      Regards

      • Graeme Lawton November 2, 2010 at 12:41 pm #

        Wow quick response, thanks! To get the formatted price on 1.4.1 I think you need to use getFormattedTierPrice() as follows.

        [code]
        <xmp><?php print_r($_product->getFormatedTierPrice()); ?></xmp>

        Array
        (
        [0] => Array
        (
        [price] => 1.6400
        [website_price] => 1.6400
        [price_qty] => 1
        [cust_group] => 32000
        [formated_price] => <span class="price">Β£1.64</span>
        )

        )

        [/code]

        On the single view this is returned (and it works fine):
        [code]
        <xmp><?php print_r($_product->getFormatedTierPrice()); ?></xmp>

        Array
        (
        [0] => Array
        (
        [price_id] => 3
        [website_id] => 0
        [all_groups] => 1
        [cust_group] => 32000
        [price_qty] => 3.0000
        [price] => 1.2000
        [website_price] => 1.2000
        [formated_price] => <span class="price">Β£1.20</span>
        )

        [1] => Array
        (
        [price_id] => 4
        [website_id] => 0
        [all_groups] => 1
        [cust_group] => 32000
        [price_qty] => 5.0000
        [price] => 1.0100
        [website_price] => 1.0100
        [formated_price] => <span class="price">Β£1.01</span>
        )

        )
        [/code]

      • quicoto November 2, 2010 at 12:45 pm #

        Can you get including / excluding TAX with that function?

  2. Graeme Lawton November 2, 2010 at 12:57 pm #

    I don’t know, I assumed the formatted_price key would display either with or without tax price depending on the back end setting.

    • quicoto November 2, 2010 at 12:58 pm #

      Oh right πŸ™‚

      Thanks for sharing it Graeme πŸ˜‰

      Regards

  3. Worm November 16, 2010 at 5:51 pm #

    Maybe i’m wrong but this code, doesn’t display ALL tier prices ? (only the lowest price)

    • quicoto November 17, 2010 at 9:03 am #

      It should display all.

      I tryied with 2 tier prices and no problem.

      Regards.

  4. Worm November 17, 2010 at 7:14 pm #

    Ok I’ve try this code (in the list.phtml)

    [code]<?php
    /* get the data */
    $my_tier_rocks = $this->getTierPrices($_product);
    if (!empty($my_tier_rocks)){
    $my_tier_rocks = $this->getTierPrices($_product);

    // Notice you may not be using formated_price_incl_tax but other field.
    $my_tier_rocks = $my_tier_rocks[0][‘formated_price_incl_tax’];
    ?>
    <? /* let’s print the data */ ?>
    <? /* Use the HTML you want just notice the $my_tier_rocks var */ ?>
    <span class="my_tier price-including-tax">
    <span class="label"><?php echo $this->__(‘As low as:’) ?></span>
    <span class="price"><?=$my_tier_rocks?></span>
    </span>

    <? } /*end showing tier prices */ ?>[/code]

    But it’s not showing tierprice.

    I’ve try this code :
    [code] print_r($this->getTierPrices($_product));[/code]

    But i’ve a blank array.

    when i try to use:
    [code]<?php echo $_product->getResource()->getAttribute(‘tier_price’)->getFrontend()->getValue($_product); ?>[/code]

    I’ve the the lowest price.

    For information i’m under 1.4.0.1

    Thanks for help !
    Regards.

    • Worm November 17, 2010 at 7:15 pm #

      To use :
      [code]<?php echo $_product->getResource()->getAttribute(‘tier_price’)->getFrontend()->getValue($_product); ?> [/code]

    • quicoto November 17, 2010 at 11:15 pm #

      Weird πŸ˜•

      If using the second code you pasted and using the $_product var returns data means $_product is not empty.

      I’m a little bit lost and don’t know what to tell you πŸ™

      If you use:

      [code]<?php echo $_product->getResource()->getAttribute(‘tier_prices’)->getFrontend()->getValue($_product); ?>[/code]

      I added a “s” just give it a try. My code use getTierPrices (plural).

      If you find any solution please post.

      Regards.

  5. Worm November 18, 2010 at 7:50 pm #

    In fact i’m trying you code in list.phtml and it’s showing tierprice .

    • Worm November 18, 2010 at 7:50 pm #

      Sorry it’s NOT showing tierprice

  6. John November 23, 2010 at 3:26 pm #

    Thanks for the code but: how can I get the entire “table” of tier prices to appear per product on category pages and not just the lowest?

    • quicoto November 23, 2010 at 3:29 pm #

      Hi John,

      I’m not sure… Did you tried to print this?

      [code]$this->getTierPrices($_product);[/code]

  7. Worm November 23, 2010 at 3:35 pm #

    Finally i’m using the code below in my list.phtml
    [code]
    <?php
    $_productCollection1 = Mage::getModel(‘catalog/product’)->getCollection()
    ->addAttributeToSelect(‘*’)
    ->addAttributeToFilter(‘status’, 1)
    ->addAttributeToFilter(‘sku’,$this->htmlEscape($_product->getSku()))
    ->load();
    foreach ($_productCollection1 as $_product1){
    $_tierPrices= $this->getTierPrices($_product1);
    foreach ($_tierPrices as $_ppr){
    echo ‘<span style="font-size:9px;">Achetez en ‘,$_ppr[‘price_qty’], ‘ Γ  ‘, number_format($_ppr[‘website_price’],2, null, ”), ‘ € par ‘, ‘<span style="text-transform:lowercase;">’, $_product->getResource()->getAttribute(‘at_bille_conditionnement’)->getFrontend()->getValue($_product),’. </span></span><br>’;
    }
    }
    ?>
    [/code]

  8. Graeme Lawton November 23, 2010 at 3:38 pm #

    Sorry, In the end, I ended up writing a custom module to do the price display in all locations. It looks up the product and pulls all he prices in, in an isolated fashion.

    I’ll tidy it up and make it public at some point, but I’m using it all over this site to display prices and it appears to be working okay.

    • quicoto November 23, 2010 at 3:39 pm #

      Would be great to know how to do it πŸ˜‰

      Regards

    • Graeme Lawton November 23, 2010 at 3:42 pm #

      As I said, I’ll clean it up and publish it.

      But the basics are if you grab a copy of the product direct from the catalog/product model you can do this in a custom block:

      [code]
      public function getPrices() {

      $prices = array(
      array(
      ‘price_qty’ => 1,
      ‘price’ => $this->getProduct()->getPrice()
      )
      );

      $prices = array_merge($prices, $this->getProduct()->getTierPrice());

      return $prices;
      }
      [/code]

  9. John November 23, 2010 at 4:36 pm #

    Hey guys – thanks for the quick responses.
    Below is the code I’m using, but I only get the first tier price.
    Any ideas?
    Here’s the page I’m trying to get them on
    http://softpouch.core101dev.com/pouches/closeout-pouches.html
    [code]
    getCollection()
    ->addAttributeToSelect(‘*’)
    ->addAttributeToFilter(‘status’, 1)
    ->addAttributeToFilter(‘sku’,$this->htmlEscape($_product->getSku()))
    ->load();
    foreach ($_productCollection1 as $_product1){
    $_tierPrices= $this->getTierPrices($_product1);
    foreach ($_tierPrices as $_ppr){
    echo ”,$_ppr[‘price_qty’], ‘ for ‘, number_format($_ppr[‘website_price’],2, null, ”), ‘ each ‘, ”, $_product->getResource()->getAttribute(‘at_bille_conditionnement’)->getFrontend()->getValue($_product),’. ‘;
    }
    }
    ?>[/code]

    • Worm November 23, 2010 at 4:55 pm #

      Sorry in my last they’re was an personal attribut !
      You must delete this :
      $_product->getResource()->getAttribute(‘at_bille_conditionnement’)->getFrontend()->getValue($_product)

      Try this :
      [code]
      <?php
      $_productCollection1 = Mage::getModel(‘catalog/product’)->getCollection()
      ->addAttributeToSelect(‘*’)
      ->addAttributeToFilter(‘status’, 1)
      ->addAttributeToFilter(‘sku’,$this->htmlEscape($_product->getSku()))
      ->load();
      foreach ($_productCollection1 as $_product1){
      $_tierPrices= $this->getTierPrices($_product1);
      foreach ($_tierPrices as $_ppr){
      echo $_ppr[‘price_qty’], ‘ for ‘, number_format($_ppr[‘website_price’],2, null, ”),’ each<br>’;
      }
      }
      ?>
      [/code]

  10. John November 23, 2010 at 5:12 pm #

    Worm, thanks SO much for your help.
    One last thing please.
    I’m only getting the tiered prices table for the first product,
    all others in list are blank.
    Here is my list.phtml file
    [code]
    <?php
    /**
    * @category design
    * @package base_default
    * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
    */
    ?>
    <?php
    /**
    * Product list template
    *
    * @see Mage_Catalog_Block_Product_List
    */
    ?>
    <?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper(‘catalog/output’);
    ?>
    <?php if(!$_productCollection->count()): ?>
    <p class="note-msg"><?php echo $this->__(‘There are no products matching the selection.’) ?></p>
    <?php else: ?>
    <div class="category-products">
    <?php echo $this->getToolbarHtml() ?>
    <?php // List mode ?>
    <?php if($this->getMode()!=’grid’): ?>
    <?php $_iterator = 0; ?>
    <ol class="products-list" id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
    <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
    <?php // Product Image ?>
    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" class="product-image"><img src="<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" /></a>
    <?php // Product description ?>
    <div class="product-shop" >
    <table border="1" cellpadding="0" cellspacing="0" width="100%">
    <tr valign="top">
    <td align="left">
    <div class="f-fix">
    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></a></h2>
    <?php if($_product->getRatingSummary()): ?>
    <?php echo $this->getReviewsSummaryHtml($_product) ?>
    <?php endif; ?>
    <?php echo $this->getPriceHtml($_product, true) ?>
    <?php if($_product->isSaleable()): ?>
    <p><button type="button" title="<?php echo $this->__(‘Add to Cart’) ?>" class="button btn-cart" onclick="setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><span><?php echo $this->__(‘Add to Cart’) ?></span></span></button></p>
    <?php else: ?>
    <p class="availability out-of-stock"><span><?php echo $this->__(‘Out of stock’) ?></span></p>
    <?php endif; ?>
    <div class="desc std">
    <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), ‘short_description’) ?>
    <!–<a href="<?php //echo $_product->getProductUrl() ?>" title="<?php //echo $this->stripTags($_product->getName(), null, true) ?>" class="link-more"><?php //echo $this->__(‘Learn More’) ?></a>//–>
    </div>
    <!–
    <ul class="add-to-links">
    <?php //if ($this->helper(‘wishlist’)->isAllow()) : ?>
    <li><a href="<?php //echo $this->helper(‘wishlist’)->getAddUrl($_product) ?>" class="link-wishlist"><?php //echo $this->__(‘Add to Wishlist’) ?></a></li>
    <?php //endif; ?>
    <?php //if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
    <li><span class="separator">|</span> <a href="<?php //echo $_compareUrl ?>" class="link-compare"><?php //echo $this->__(‘Add to Compare’) ?></a></li>
    <?php //endif; ?>
    </ul>
    //–>
    </div>

    </td>
    <td width="50%">
    <!– tier prices //–>

    <?php //echo $this->getTierPriceHtml($_product) ?>

    <?php

    $_productCollection1 = Mage::getModel(‘catalog/product’)->getCollection()
    ->addAttributeToSelect(‘*’)
    ->addAttributeToFilter(‘status’, 1)
    ->addAttributeToFilter(‘sku’,$this->htmlEscape($_product->getSku()))
    ->load();
    foreach ($_productCollection1 as $_product1){
    $_tierPrices= $this->getTierPrices($_product1);
    foreach ($_tierPrices as $_ppr){
    echo $_ppr[‘price_qty’], ‘ for ‘, number_format($_ppr[‘website_price’],2, null, ”),’ each<br>’;
    }
    }

    ?>

    <!– /tier prices //–>

    </td>
    </tr>

    </table>
    </div>
    </li>
    <?php endforeach; ?>
    </ol>
    <script type="text/javascript">decorateList(‘products-list’, ‘none-recursive’)</script>

    <?php else: ?>

    <?php // Grid Mode ?>

    <?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
    <?php if ($i++%$_columnCount==0): ?>
    <ul class="products-grid">
    <?php endif ?>
    <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" class="product-image"><img src="<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" /></a>
    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), ‘name’) ?></a></h2>
    <?php if($_product->getRatingSummary()): ?>
    <?php echo $this->getReviewsSummaryHtml($_product, ‘short’) ?>
    <?php endif; ?>
    <?php echo $this->getPriceHtml($_product, true) ?>
    <div class="actions">
    <?php if($_product->isSaleable()): ?>
    <button type="button" title="<?php echo $this->__(‘Add to Cart’) ?>" class="button btn-cart" onclick="setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><span><?php echo $this->__(‘Add to Cart’) ?></span></span></button>
    <?php else: ?>
    <p class="availability out-of-stock"><span><?php echo $this->__(‘Out of stock’) ?></span></p>
    <?php endif; ?>
    <ul class="add-to-links">
    <?php if ($this->helper(‘wishlist’)->isAllow()) : ?>
    <li><a href="<?php echo $this->helper(‘wishlist’)->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__(‘Add to Wishlist’) ?></a></li>
    <?php endif; ?>
    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
    <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__(‘Add to Compare’) ?></a></li>
    <?php endif; ?>
    </ul>
    </div>
    </li>
    <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
    </ul>
    <?php endif ?>
    <?php endforeach ?>
    <script type="text/javascript">decorateGeneric($$(‘ul.products-grid’), [‘odd’,’even’,’first’,’last’])</script>
    <?php endif; ?>

    <div class="toolbar-bottom">
    <?php echo $this->getToolbarHtml() ?>
    </div>
    </div>
    <?php endif; ?>

    [/code]

  11. Worm November 24, 2010 at 11:23 am #

    Hi John,
    Are you sure they are some tierprices in your other product ? because when i’m looking the 2 last products they are no tier prices.
    An another way, in the second product (new group …) maybe it’s not a simple product.

    • VildUlv October 28, 2011 at 12:37 pm #

      Worm, thanks for your help.

  12. shubh October 18, 2011 at 6:32 am #

    hi friends

    I want to display Tier price on product list page in such a way the product are in tabular form and there quantity and price mention in front of these product………..

    Any help or idea for these here is example below

    Products Qty Price

    ABC 50 100$

    XYZ 100 50$

    • Rick October 18, 2011 at 8:29 am #

      Looks like you just want to customize the output.

      Have you tried to print what the tier_prices return and build your own table ?

  13. David Manners October 19, 2011 at 4:16 pm #

    Hi,

    I am looking to show all the tier price options for a product on the search results page. I have tried getTierPrices (which returns an empty array). I have also tried loading the price model and getting it that way but that only seems to load one.

    I also tired getTierPriceHtml but that caused a fatal error: “Call to a member function isGrouped() on a non-object in”.

    Any help would be great thanks.

    • David Manners October 19, 2011 at 4:26 pm #

      Sorry was being a bit of a fool. The first product in my search results did not have tiered pricing.

    • Rufat May 27, 2012 at 8:22 pm #

      Hello!

      Bug is here:
      app\code\core\Mage\Catalog\Block\Product\Abstract.php

      You should replace function getTierPriceHtml with this:

      [code]
      public function getTierPriceHtml($product = null)
      {
      if (is_null($product)) {
      $product = $this-&gt;getProduct();
      }
      return $this-&gt;_getPriceBlock($product-&gt;getTypeId())
      -&gt;setTemplate($this-&gt;getTierPriceTemplate())
      -&gt;setProduct($product)
      -&gt;setInGrouped($product-&gt;isGrouped())
      -&gt;toHtml();
      }

      [/code]
      here was mistake: ->setInGrouped($this->getProduct()->isGrouped())

      it replaced with:
      ->setInGrouped($product->isGrouped())

  14. tuba March 14, 2012 at 11:36 pm #

    Thank you for the tutorial, however seems not working on 1.6.

    • Rick March 14, 2012 at 11:39 pm #

      I haven’t tried with the 1.6

      They may have changed something.

      Does it show any error?

      Regards

  15. tuba March 15, 2012 at 1:30 am #

    only prints blank: array()
    no errors

    • Rick March 15, 2012 at 8:14 am #

      Just to make sure, double check the product has tier prices.

      Then try:

      [code]print_r($this->getTierPrices($_product));[/code]

      Regards

  16. Enrique Piatti March 22, 2012 at 7:22 pm #

    This doesn’t work in the new versions of magento, because the tier prices are not loaded in the collection when you are listing products. The solution provided by @Worm works but it’s really really inefficient, because it makes a new SQL query for every product and retrieving everything. And also is a bit confusing because he’s is using a collection for only one product and filtering by “sku” and other things, this is the correct way of doing the same:

    [code]
    $_product1 = Mage::getModel( ‘catalog/product’ )->load( $_product->getId() );
    $_tierPrices = $this->getTierPrices( $_product1 );
    foreach ($_tierPrices as $_ppr)
    {
    echo $_ppr[‘price_qty’], ‘ for ‘, number_format( $_ppr[‘website_price’], 2, null, ” ), ‘ each’;
    }
    [/code]

    But how I said, that’s really ineeficient and unnecessary.
    The best and simple solution is just executing “addTierPriceData” on the current collection before trying to read the tier prices.

    For example:
    catalog/product/list.phtml:
    [code]
    $_productCollection=$this->getLoadedProductCollection();
    $_productCollection->addTierPriceData(); // this is new
    [/code]

    • Rick March 22, 2012 at 8:32 pm #

      Thanks for the clarification Enrique! πŸ˜‰

  17. Steve July 25, 2012 at 11:28 am #

    Hi Enrique,

    I tried adding $_productCollection->addTierPriceData(); // this is new after line 35.
    But it still isn’t showing.

    I only have one tier price filled in Magento 1.6.

    The problem is I only get “as low as” which basically doesn’t say much for customers viewing the page.

    How can I show more?

  18. Rakesh Patel January 15, 2013 at 7:21 pm #

    for display low price only with currency and floating format.

    Thanks,
    Rakesh Patel

    • Rick January 15, 2013 at 10:42 pm #

      Cheers πŸ˜‰

  19. Anthony February 21, 2013 at 6:56 pm #

    I need a table with all the prices from the tier price and qty on top on the products page in magento 1.7.0.2.

    I am new to this and you would think a e-commerce system would make this easy. Any thoughts?

  20. Justin Snyder August 6, 2016 at 12:23 pm #

    Any ideas how to show the tier pricing in magento 2.0?

    • Rick August 9, 2016 at 1:23 pm #

      No idea I’m afraid. I’ve been away from Magento development for a long time.

Leave a Reply

Add <code> Some Code </code> by using this tags.