TOPIC: Looking to move Shopping Cart to Header-Right in Magento 1.8.1


How to add a Cart Icon to header?

Move Cart to Header in Magento 1.7

Any contribution is greatly appreciated.

Shopping Cart Icon & # Of Products In Cart - DISPLAYED AT RIGHT-HEADER is the end goal.

  1. in yourTheme/layout/local.xml
<!-- Unset cart from sidebar -->    
    <reference name="right"><action method="unsetChild"><name>cart_sidebar</name></action></reference>
    <!-- Insert cart in header -->
    <reference name="header"><action method="insert"><blockName>cart_sidebar</blockName></action></reference>
  1. in yourTheme/template/page/html/header.phtml:
// This is required to show the cart
<?php echo $this->getChildHtml('cart_sidebar'); ?>

Normaly the cart should appear in the header.

Edit yourTheme/template/checkout/cart/sidebar.phtml to give the look you want.

  • Hi, thank you for the post. I did not find local.xml in the Layout folder. I found a local.xml in /app/etc folder? Should I create a new local.xml in the /Layout folder or edit the one in /etc folder? – JasonC91 Oct 17 '14 at 11:42
  • Create app/design/frontend/yourPackage(default?)/yourTheme/layout/local.xml. Then do every layout modifications in local.xml. This way you'll keep your customizations in case of Magento Update – Lanks Oct 17 '14 at 11:45
  • I updated my answer concerning the local.xml file. Please try again – Lanks Oct 17 '14 at 12:21
  • I changed the code to the updated one, no change :/, and flushed cache etc. – JasonC91 Oct 17 '14 at 12:57
  • Please give me the exact path of your local.xml. Also did you well configurated your Magento Theme in System > Configuration > Design Tab > Package & Theme ? Maybe this link can help : magentocommerce.com/design_guide/articles/… – Lanks Oct 17 '14 at 13:02

In Local.xml add this :

<reference name="header">
            <!-- add cart to header -->
            <block type="checkout/cart_sidebar" name="header-cart" template="checkout/cart/header-cart.phtml">
                <action method="addItemRender"><type>simple</type>
                <action method="addItemRender"><type>grouped</type>
                <action method="addItemRender"><type>configurable</type>
                <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                    <label>Shopping Cart Sidebar Extra Actions</label>

In header.phtml add this :

<?php echo $this->getChildHtml('header-cart'); ?>

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.