I have items in cart. But it returns empty array when fetching them. I don't know what is the problem. I used following code for getting the number of items in cart and it gives 0.But in my site I have items in the cart.
$totalItems = Mage::helper('checkout/cart')->getItemsCount();
echo $totalItems;
$session= Mage::getSingleton('checkout/session');
foreach($session->getQuote()->getAllVisibleItems() as $item)
{
$productid = $item->getProductId();
$productsku = $item->getSku();
$productname = $item->getName();
$productqty = $item->getQty();
echo $productid;
}
I hope someone will help on this issue.
Best Answer
Try this code