How do I insert a custom block
right above the coupon code field in the shopping cart by just using the layout.xml
(without editing the template using getChildHtml()
).
I had done it before now i just cant seem to remember the block name..
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow do I insert a custom block
right above the coupon code field in the shopping cart by just using the layout.xml
(without editing the template using getChildHtml()
).
I had done it before now i just cant seem to remember the block name..
Add the following code in your themes local.xml and check.
<checkout_cart_index translate="label">
<reference name="checkout.cart">
<block type="core/template" before="coupon" name="sample" template="sample.phtml"/>
</reference>
</checkout_cart_index>
Magento provides a placeholder for extensions or custom blocks that you can use which is called checkout.cart.extra
as you can see from the cart.phtml
template:
<div class="col-2">
<?php /* Extensions placeholder */ ?>
<?php echo $this->getChildHtml('checkout.cart.extra') ?>
<?php echo $this->getChildHtml('coupon') ?>
<?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
</div>
So you can totally do the following in your local.xml
file:
<checkout_cart_index>
<reference name="checkout.cart">
<block type="core/text_list" name="checkout.cart.extra" translate="label">
<label>Checkout Forms Extra</label>
<block type="core/template" name="my.custom.block" template="path/to/template.phtml"/>
</block>
</reference>
</checkout_cart_index>