0

I need to add a block on magento default checkout page i.e in cart.phtml file. So first step I did is, I added a block of code in checkout.xml file in the section

     <reference name="content">
      <block type="checkout/cart" name="checkout.cart"> .....

Here is my code

     <block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller.phtml"/>

and then in second step i just called its child html section as

      <div style="width:220px; float:right;"><?php echo $this->getChildHtml('bestseller');?>   </div>

But the problem is when I came to see its frontend I seen this bestseller block is appearing two times on the same checkout page. I don't know what m doing wrong. !!pLease someone help me !

4
  • where you added these config in xml layout file? Commented Apr 14, 2014 at 6:53
  • 1
    Put full checkout.xml and cart.phtml in your questions Commented Apr 14, 2014 at 6:59
  • <block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller.phtml"/> </checkout_cart_index>. just above the line where checkout_cart_index is closing Commented Apr 14, 2014 at 7:01
  • Where cart.phtml??????? Commented Apr 14, 2014 at 7:10

1 Answer 1

2

I recently did this with no issues, here are my steps:

Step 1: make a local.xml file inside your theme inside your layout folder (yourtheme/layout/local.xml).

<!-- language: lang-xml -->
    <?xml version="1.0"?>
    <layout version="0.1.0">
        <checkout_cart_index>
            <reference name="checkout.cart">
                <block type="vendorname_modulename/blockname" name="your.name.here" as="your.name.here" template="path/to/template.phtml" />
            </reference>
        </checkout_cart_index>
    </layout>

Step 2: copy the cart.phtml to your theme (mimicking the folder structure: yourtheme/template/checkout/cart.phtml)

Step 3: add this line of code inside the cart template.

<?php echo $this->getChildHtml('your.name.here');

As a side note there are many ways to accomplish this,I hope this helps. good luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.