Return to Snippet

Revision: 39904
at January 22, 2011 10:58 by silky


Initial Code
<?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));
?>

Initial URL
http://shamimcse05.wordpress.com/2010/12/23/how-to-get-total-cart-item-and-total-price-in-magento/

Initial Description
To display it in a cms page,
{{block type="checkout/cart" block_id="my_block" template="path_to_.phtml"}}

Initial Title
PHP code to display number of cart items and grand total in magento

Initial Tags


Initial Language
PHP