Sunday, September 25

How to move Cart from Right Sidebar to Header in Magento?

Here is the detailed steps to move the cart from right sidebar to header

Find the below line in your page.xml file.
<block as="header" name="header" type="page/html_header"> //Near line 70
</block>

Add the below code inside to that block
<block as="topcart" name="cart_sidebar" template="checkout/cart/sidebar.phtml" type="checkout/cart_sidebar">
</block>

Your new code will look like this
<block as="header" name="header" type="page/html_header">
        <block as="topLinks" name="top.links" type="page/template_links">
        <block as="store_language" name="store_language" template="page/switch/languages.phtml" type="page/switch">
        <block as="topMenu" name="top.menu" translate="label" type="core/text_list">
            <label>Navigation Bar</label>
        </block>
        <block as="topContainer" name="top.container" translate="label" type="page/html_wrapper">
            <label>Page Header</label>
            <action method="setElementClass"><value>top-container</value></action>
        </block>
 //new block 
 <block as="topcart" name="cart_sidebar" template="checkout/cart/sidebar.phtml" type="checkout/cart_sidebar">
</block>
</block></block></block>

Finally Add the below code in your "\template\page\html\header.phtml" file.
//place this where ever you want the cart to show up.
<?php echo $this->getChildHtml('topcart'); ?>

Thats it. You can see the cart sidebar in your header section.

Hope it Helps... Thanks....

No comments:

Post a Comment