Pages

Wednesday 7 January 2015

Magento:: Display Shopping Cart in Header

Go to app\design\frontend\Your_theme\default\template\page\html\header.phtml
Add the following code inside the header-container div to display 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));
?>

No comments:

Post a Comment