11/18/2011

How to show cart quantity in magento


Hello Everyone,

              Today I’m going to tell you about how to show cart quantity in magento.In simple words, This tutorial will tell to add cart quantity anywhere in page according to client requirement.For example My clients requirement was to show cart quantity in shopping cart in header as shown here 
Baba N Baby

       For this, you need to Copy paste the following code to your file where you want to show the quantity.For example i wanted to show quantity in header so i need to edit header.phtml file.Similarly you can edit left column, right column etc.

Code to show cart Quantity :

<?php 
  function getCartQuantity () {
   $cart = Mage::getModel('checkout/cart')->getQuote()->getData();
   if (isset($cart['items_qty']))
   return (int)$cart['items_qty'];
   else
    return 0;
  }
  echo getCartQuantity ();  
?> 

 So in this way you can add cart quantity to some image like 





Start your Ecommerce website at just Rs .10000

Contact : Renderindia Infotech Bangalore
Bangalore Branch Office

110 , 5th cross, ITPL main road , Kundanhalli Colony
 Bangalore :-  560037.
 Mobile no :- 91-8123481528 (Ashish Khadpe)
 Mobile no :- 91-9769941316 (Rehan Sheikh)


No comments:

Post a Comment