开发者

Display Tiered Pricing on the Cart page

开发者 https://www.devze.com 2023-04-05 17:52 出处:网络
If Im on this page: http:///checkout/cart/ With products in my cart I would like to display the tiered pricing, the same that is shown on the item page, if available.

If Im on this page: http:///checkout/cart/

With products in my cart I would like to display the tiered pricing, the same that is shown on the item page, if available.

My attempt was add

<checkout_cart_index>
    <block type="catalog/product_view" name="product.tierprices" as="tierprices" template="catalog/product/view/tierprices.phtml"/>
    </checkout_cart_index>

to my xml file and add

<?php echo $this->开发者_运维知识库getChildHtml('tierprices') ?>

to

\app\design\frontend\enterprise\<mytemplate>\template\checkout\cart\item\default.phtml

Doesn’t do anything - any further suggestions?


It seems impossible to easily change layout. You need to modify item renderer and add tier price displaying manually. To fetch list of available tier prices you need to get price model. You can get it from product model

$product->getPriceModel()

or if don't have product model try the following code

Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId)

Quote item contains product type information.

When you have price model just call method getTierPrice() to get all tier prices as array.

$priceModel->getTierPrice()


You could edit the .phtml file and adding the $this->getTierPrices($_product);//or$this->getTierPrices($_item); if you simply want to display the tier prices of products.

Do note that the getTierPrices() only works when being on the product list or product view page, so you would need to copy the getTierPrices() method that can be found inside the List.php to your custom module.


This should give you an idea what needs to be done.

layout file

<?xml version="1.0"?>
<layout version="0.1.0">
    <checkout_cart_index>
        <reference name="additional.product.info">
            <block type="LokeyCoding_Cart/TierPrice" name="additional.product.info.tierprice" />
        </reference>
    </checkout_cart_index>
</version>

block file

<?php
class LokeyCoding_Cart_Block_TierPrice extends Mage_Core_Block_Abstract
{
    protected function _toHtml()
    {
        $parent = $this->getParentBlock();
        if ($parent) {
            $item = $parent->getItem();
            if ($item instanceof Mage_Sales_Model_Quote_Item) {
                return $item->getProduct()->getTierPriceHtml();
            }
        }

        return '';
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消