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


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. <?php
  2. $count = $this->helper('checkout/cart')->getSummaryCount(); //get total items in cart
  3. $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  4. if($count==0)
  5. {
  6. echo $this->__('Items: %s',$count);
  7. }
  8. if($count==1)
  9. {
  10. echo $this->__(' Item: %s',$count);
  11. }
  12. if($count>1)
  13. {
  14. echo $this->__(' Items: %s',$count);
  15. }
  16. echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
  17. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.