Posted By

silky on 01/22/11


Tagged


Versions (?)

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


 / Published in: PHP
 

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

To display it in a cms page, {{block type="checkout/cart" blockid="myblock" template="pathto.phtml"}}

  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. ?>

Report this snippet  

You need to login to post a comment.