i am adding the block through xml on cart page. i searching a lot but could not find the find the solution where i am getting wrong.


    <reference name="checkout.cart">

            <block type="test/test" before="coupon"   template="test/cart_test.phtml" />


when i and the block is added to cart page but i want to add before the coupon block any help will be appreciated.

  • call your custom block before coupon – saravanavelu Aug 3 '15 at 10:00

Try like this,

<reference name="checkout.cart">

   <block type="test/test" before="coupon" name="custom-block"  template="test/cart_test.phtml" />


call your custom block before coupon in app\design\frontend\package\theme\template\checkout\cart.phtml,

<?php echo $this->getChildHtml('custom-block'); ?>

 <?php echo $this->getChildHtml('coupon') ?>
  • i tried but it's not working for me – Qaisar Satti Aug 3 '15 at 10:06
  • 2
    check your custom block and template is correctly defined – saravanavelu Aug 3 '15 at 10:08
  • yes if i change <reference name="content"> . it is showing – Qaisar Satti Aug 3 '15 at 10:17
  • @QaisarSatti Have you put the $this->getChildHtml('custom-block'); in your cart.phtml – Bhupendra Jadeja Aug 3 '15 at 10:43
  • yes i put it but it is not showing anything.. – Qaisar Satti Aug 3 '15 at 10:49

that was work for me

<?php echo  Mage::app()->getLayout()
            ->toHtml(); ?>

Try this way:

    <reference name="checkout.cart">
            <block type="test/test" before="checkout.cart.coupon"   template="test/cart_test.phtml" />

Hope this helps.

  • no it is not working.. – Qaisar Satti Aug 3 '15 at 9:44
  • Hope you have cleared cache as well. – Adarsh Khatri Aug 3 '15 at 9:46
  • still not luck :( – Qaisar Satti Aug 3 '15 at 9:47

If the XML isn't working for you then the easiet way to inject your cms block is the php code snippet.

Try the following and it will inject the block:

  • Open your cart.phtml file and locate the div/html section where you would like your block to appear and paste the following code there.

    <?php echo $this->getLayout()->createBlock("cms/block")->setBlockId("your-static-block-id")->toHtml();?>

  • i am creating the ext bro – Qaisar Satti Aug 3 '15 at 15:00
  • Okay, in that case, have you tried clearing your cache? Make sure it's disabled whilst your project is in dev mode. Have you also tried to inject any other block except the one you created? Is the block set to enabled? What is the scope of the static block? – Shoaib Rehman Aug 4 '15 at 15:12
  • it is developer mode and cache is disabled.no other block in added there. – Qaisar Satti Aug 4 '15 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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