2

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.

<checkout_cart_index>

    <reference name="checkout.cart">

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

    </reference>
</checkout_cart_index>

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

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

Try like this,

<reference name="checkout.cart">

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

</reference>

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

that was work for me

<?php echo  Mage::app()->getLayout()
            ->createBlock('test/test')
            ->setTemplate('test/test.phtml')
            ->toHtml(); ?>
1

Try this way:

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

Hope this helps.

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

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

3
  • i am creating the ext bro 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? Aug 4 '15 at 15:12
  • it is developer mode and cache is disabled.no other block in added there. 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.