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..


2 Answers 2


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"/>
  • this doesnt place above the "discount coupon" box
    – anant
    Commented Sep 30, 2016 at 12:36

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; ?>

So you can totally do the following in your local.xml file:

    <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"/>
  • i would like to do it without hardcoding into templates, I know there is wa way, i just forgot the block name
    – anant
    Commented Sep 30, 2016 at 12:37
  • @anant well read my solution again. The template code is from the core you don't have to exit the template simply use the layout code I pasted Commented Sep 30, 2016 at 12:50
  • but it is not inserting the block right above the discount block
    – anant
    Commented Oct 4, 2016 at 13:53
  • how to add block in admin order create page ? layout xml @RaphaelatDigitalPianism Commented Nov 5, 2016 at 6:15
  • @lalitmohan that's a totally different question please create a new question Commented Nov 5, 2016 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.