我正在尝试在结帐页面上更改项目渲染器的模板。以下是checkout.xml中设置此渲染器的部分。
<block type="checkout/onepage_review_info" name="root" output="toHtml" template="checkout/onepage/review/info.phtml">
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
<block type="checkout/cart_totals" name="checkout.onepage.review.info.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
<block type="core/text_list" name="checkout.onepage.review.info.items.before" as="items_before" translate="label">
<label>Items Before</label>
</block>
<block type="core/text_list" name="checkout.onepage.review.info.items.after" as="items_after" translate="label">
<label>Items After</label>
</block>
<block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
<block type="core/template" name="checkout.onepage.review.button" as="button" template="checkout/onepage/review/button.phtml"/>
</block>
我想为可配置产品更改它。我不确定哪种解决方案最好。
答案 0 :(得分:1)
您可以通过local.xml文件更改项呈示器。如果该文件尚不存在,您可以在app/design/frontend/[your_package]/[your_theme]/layout/
文件夹中创建一个文件。
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_onepage_review>
<reference name="root">
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>path/to/your/file/item.phtml</template></action>
</reference>
</checkout_onepage_review>
</layout>
如果您查看addItemRender
类中的Mage_Sales_Block_Items_Abstract
方法,您会明白为什么会这样做。
public function addItemRender($type, $block, $template)
{
$this->_itemRenders[$type] = array(
'block' => $block,
'template' => $template,
'renderer' => null
);
return $this;
}
希望这有帮助!