Magento – How to set quantity of cart as 0 programmatically

cartquantity

I want to programm Magento in such a way that the quantity of cart displays zero even if the product is Added into the cart. Initially there will be one product into cart but it hasn't to be displayed on the top menu cart link

I have used following code but I don't get enough response.

Mage::getModel('checkout/cart')->getQuote()->setItemsQty(0);

Best Answer

Clear shopping cart

foreach (Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ) {
    Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
}

If you want to Clear entire session

Mage::getSingleton('checkout/session')->clear();