Sunday, July 15, 2012

Magento: Display Shopping cart on the header

In magento we have the option to display shopping cart in the header position.

Go to the app\design\frontend\default\YOUR THEME\template\page\html

In this html folder find the header.phtml file

If header.phtml is not available in your theme goto the base in the below url

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

to place the followinig code under "header-container" div, now we can able to view total number of  items and price in header.

<?php
  $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
  $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  if($count==0)
  {
    echo $this->__('Items: %s',$count);
  }
  if($count==1)
  {
    echo $this->__(' Item: %s',$count);
  }
  if($count>1)
  {
    echo $this->__(' Items: %s',$count);
  }
  echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>

Please update your comments/feedback to improve in our magento knowledge.

By PHP with No comments

0 comments:

Post a Comment

    • Popular
    • Categories
    • Archives