Magento product view page display tier in table format

Hi,

Magento default tier price display in row please see in image now i have display tier price in table format i have add code in view.phtml file and you use this code on app/design/frontend/base/default/template/catalog/product/view/tierprices.phtml but first crate backup file for tierprices.phtml and next change code :)

open app/design/frontend/base/default/template/catalog/product/view.phtml file and copy and past this code when you display tierprice
<!-- Display product tier price -->
            <?php
$_product = $this->getProduct();
$_tierPrices = $this->getTierPrices();
if (count($_tierPrices) > 0):
    $_data = array();
    $_prevQty = 0;
    $_counter = 0;
    $_tierPrices = array_reverse($_tierPrices);
    foreach ($_tierPrices as $_index => $_price){
        $_counter++;
            $label = $_price['price_qty'];
            $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price'],'save'=>$_price['savePercent']);
            $_prevQty = $_price['price_qty'];
    }
    $_data = array_reverse($_data);
?>
    <table class="tiered-pricing">
        <tbody>
            <tr>
                <th>Quantity</th>
                <th>Price</th>
                <th>Save</th>
            </tr>
        <?php foreach ($_data as $_row): ?>
            <tr>
                <td><?php echo $_row['label']; ?></td>
                <td><?php echo $_row['price']; ?></td>
                <td><?php echo $_row['save']."%"; ?></td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
<?php
endif;
?>
            <!-- Display product tier price -->

And you can display tierprice  this style


<!-- Display product tier price -->
            <?php
            $_product = $this->getProduct();
            $_tierPrices = $this->getTierPrices();
            if (count($_tierPrices) > 0):
                $_data = array();
                $_prevQty = 0;
                $_counter = 0;
                $_tierPrices = array_reverse($_tierPrices);
                foreach ($_tierPrices as $_index => $_price){
                    $_counter++;
                    if($_price['price_qty']>$_prevQty){
                        $label = $_price['price_qty']. '+';
                        $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price'],'save'=>$_price['savePercent']);
                        $_prevQty = $_price['price_qty']-1;
                    } else {
                        $label = $_price['price_qty'] . '-' . $_prevQty;
                        $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price'],'save'=>$_price['savePercent']);
                        $_prevQty = $_price['price_qty']-1;
                    }
                }
                $_data = array_reverse($_data);
            ?>
                <table class="tiered-pricing">
                    <tbody>
                        <tr>
                            <th>Quantity</th>
                            <th>Price</th>
                            <th>Save</th>
                        </tr>
                    <?php foreach ($_data as $_row): ?>
                        <tr>
                            <td><?php echo $_row['label']; ?></td>
                            <td><?php echo $_row['price']; ?></td>
                            <td><?php echo $_row['save']."%"; ?></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            <?php
            endif;
            ?>
            <!-- Display product tier price -->



2 comments:

  1. You can try Magento Percentage Tier Price extension by BSSCommerce: http://bsscommerce.com/magento-percentage-off-tiered-pricing.html
    The extension extends default Magento Tier Price function by allowing admins to define tier prices as a percentage.
    See more useful features:
    +Easily set up tier price based on standard price or group price
    +Set tier price in a fixed amount or in percentage
    +Automatically update tier price when price is changed

    ReplyDelete
  2. I do agree with all the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time?..Keep this great work
    magento development company in bangalore 

    ReplyDelete