Showing magento cart items quantity and price on header

Sometimes in magento our client want magento cart items quantity and price on header. Recently I have experienced it and solve it. Now you can easily do this just following the below step:

 

First step:

To do this, first you need to edit  header.phtml which is located on

app/design/frontend/your-instance-name/your-theme-name/template/page/html/header.phtml

If it not located there, then you can find it on this following location:

app/design/frontend/base/default/template/page/html/header.phtml

Now paste the below code where you need to show the magento cart items quantity and price.

<?php
    $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
    if($count==0)
        {
            echo $this->__('<div><div></div><p><span>0</span> items</p></div>',$count);
            }
        if($count==1)
        {
        echo $this->__('<div><div></div><a href="/checkout/cart"><p><span>1</span> item</p></a></div>',$count);
        }
        if($count>1)
        {
        echo $this->__('<a href="/checkout/cart"><div><div></div><a href="/checkout/cart"><p><span>%s</span> items</p></a></div>',$count);
        }
?>
        <strong><?php echo Mage::helper('checkout')->formatPrice(Mage::getModel('checkout/session')->getQuote()->getGrandTotal()) ?></strong>

Now check your site header, the magento cart items quantity and price are showing. Then apply CSS and give the look as you want.

No comments yet.

Leave a Reply