Magento move cart to header

# xml config
<?xml version="1.0" encoding="UTF-8"?>
<!--
	./app/design/frontend/default/default/layout/local.xml
-->
<layout>
	<default>
        <remove name="checkout_cart_link"/>     <!-- remove My Cart and Checkout from haeder -->
        <remove name="cart_sidebar"/>
 
        <reference name="header">
            <block type="checkout/cart_sidebar" name="cart_topbar" as="topCart" template="checkout/cart/topbar.phtml"/>
        </reference>
    </default>
</layout>
 
 
 
# header
./app/design/frontend/default/default/template/page/html/header.phtml
add
<?php echo $this->getChildHtml('topCart')?>
 
 
# style
./skin/frontend/default/default/css/styles.css
add
.header .block-cart {
   width:195px;
   float:right;
   margin-bottom:0px;
}
 
.block-cart .block-content {
    border: none;
    -moz-box-shadow: 0px 0px 0px #0C0C0C;
    background: #E4DFD4;
    height: 47px;
}
 
.block-cart .amount {
    color:#000000;
    padding-top: 4px;
    text-align: center;
}
 
.block-cart .summary {
    background:none repeat scroll 0 0 #E4DFD4;
    color:#fff;
    padding: 2px 8px 4px;
}
 
.block-cart .subtotal {
    background:none repeat scroll 0 0 #470615;
}
 
# translation
sed -i 's|,"Zum Warenkorb"|,"Warenkorb anzeigen"|g' ./app/locale/de_DE/Mage_Customer.csv
sed -i 's|,"Vers le panier"|,"Consulter panier"|g' ./app/locale/fr_FR/Mage_Customer.csv
sed -i 's|,"Régler mes achats"|,"Caisse"|g' ./app/locale/fr_FR/Mage_Checkout.csv
 
# ./app/design/frontend/default/default/template/checkout/cart/topbar.phtml
<?php
/**
 * ./app/design/frontend/default/default/template/checkout/cart/topbar.phtml
 *
 * based on ./app/design/frontend/base/default/template/checkout/cart/sidebar.phtml
 */
?>
<div class="block block-cart">
    <?php $_cartQty = $this->getSummaryCount() ?>
    <div class="block-title">
        <strong><span><?php echo $this->__('My Cart') ?></span></strong>
    </div>
    <div class="block-content">
    <?php if ($_cartQty > 0): ?>
        <div class="summary">
            <p class="subtotal">
                <a href="<?php echo $this->getUrl('checkout/cart'); ?>">
                <?php echo $_cartQty . ' '; ?>
                <?php if ($_cartQty == 1): ?>
                    <?php echo $this->__('Item') ?>
                <?php else: ?>
                    <?php echo $this->__('Items') ?>
                <?php endif ?>
                |
                <?php echo $this->__('Total') ?>: <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
                </a>
            </p>
            <p class="amount">
                <a href="<?php echo $this->getUrl('checkout/cart'); ?>"><?php echo $this->__('To Cart') ?></a> | 
                <a href="<?php echo $this->getUrl('checkout'); ?>"><?php echo $this->__('Checkout') ?></a>
            </p>
        </div>
    <?php else: ?>
        <p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p>
    <?php endif ?>
    </div>
</div>
 
execute this:
mkdir -p ./app/design/frontend/default/default/template/checkout/cart
wget http://www.panticz.de/sites/default/files/magento/cart/topbar.phtml -O ./app/design/frontend/default/default/template/checkout/cart/topbar.phtml
 
 
# OPTIONAL: HowTo edit Wishlist
mkdir -p  code/local/Mage/Wishlist/Block
cp ./app/code/core/Mage/Wishlist/Block/Links.php ./app/code/local/Mage/Wishlist/Block/Links.php
 
 
# Links
http://www.magentocommerce.com/boards/viewthread/13046/
http://shamimcse05.wordpress.com/2010/12/23/how-to-get-total-cart-item-and-total-price-in-magento/

Comments

Thank you very much!! This is

Thank you very much!! This is the best way to do it I´ve found, works perfect, I´d like to support your site but there´s no ad to click on. Cheers!

And in top.links?

Thanks for the tutorial! I works for me although i'm a newbie.

I'll prefer to place the Cart in the top.links block, but it doesn't show although I modify the top.links.phtml file like header.phtml. Can You help?

This is the XML in the local.xml ...

By the way you have a typo in the title haeder -> header.