Magento 1.9 – How to Add a Custom Block to Cart Sidebar

cartmagento-1.9template

I created my custom CMS block in Magento, with identifier info_cart.
I changed the checkout.xml file and the cart page now has to 2 columns with right sidebar (instead of 1 column).

<reference name="root">
        <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
    </reference>

I also added this piece of code

<reference name=checkout.cart>
  <block type=cms/block name=info_cart>
     <action method=setBlockId><block_id>info_cart</block_id></action>
  </block>
</reference>

Which displays the content from the custom block. But the content is displayed at the bottom of the page, not in the sidebar, on the right side of the page. Where should I put <?php echo $this->getChildHtml('info_cart'); ?> to be display on the right sidebar instead of bottom of the page?

EDIT:
I update the text with the full cod of checkout.xml

<checkout_cart_index translate="label">
        <label>Shopping Cart</label>
        <remove name="right"/>
        <remove name="left"/>
        <!-- Mage_Checkout -->
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
        <reference name="breadcrumbs">
            <action method="addCrumb"><crumbName>home</crumbName><crumbInfo><label>Home</label><title>Home</title></crumbInfo></action>
            <action method="addCrumb"><crumbName>shopping_cart</crumbName><crumbInfo><label>Shopping Cart</label><title>Shopping Cart</title></crumbInfo></action>
        </reference>
        <reference name="content">
            <block type="checkout/cart" name="checkout.cart">
                <action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
                <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
                <action method="chooseTemplate"/>
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>

                <block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
                    <label>Payment Methods Before Checkout Button</label>
                    <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                </block>

                <block type="page/html_wrapper" name="checkout.cart.form.before" as="form_before" translate="label">
                    <label>Shopping Cart Form Before</label>
                </block>

                <block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
                    <label>Payment Methods After Checkout Button</label>
                    <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                    <block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>
                </block>

                <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
                <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>

                <block type="core/text_list" name="checkout.cart.replace.crosssell" as="replace.crosssell" translate="label">
                    <label>Shopping Cart Sample Block Replace With Crosssell</label>
                </block>
                <block type="themeframework/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

                <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
            </block>
        </reference>
        <block type="core/text_list" name="additional.product.info" translate="label">
            <label>Additional Product Info</label>
        </block>

        <reference name="right"> <!-- or left, whatever -->
        <block type="cms/block" name="info_cart">
            <action method="setBlockId"><block_id>info_cart</block_id></action>
        </block>
        </reference>
    </checkout_cart_index>

Best Answer

try below code

<reference name="right">
  <block type=cms/block name=info_cart>
     <action method=setBlockId><block_id>info_cart</block_id></action>
 </block>
</reference>

Right block has core/text_list type of block so you dont need to write <?php echo $this->getChildHtml('info_cart'); ?>

Edit

In your handler checkout_cart_index comment out below code

<remove name="right"/>
<remove name="left"/>

The above code responsible not to load left and right section

Related Topic