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.


Clear shopping cart

foreach (Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ) {

If you want to Clear entire session


If you have a large number of customers quotes then deleting them by using loop might be time and resource consuming. You can clear/delete all customers cart items (all active sales quotes) by using the following SQL query:

DELETE FROM sales_flat_quote WHERE is_active = 1;

is_active = 0 means those quotes have been converted into orders, i.e. customer has placed order for those quotes.

is_active = 1 means quotes that have not been ordered, i.e. quotes present in the shopping cart of customers

Running this query will automatically delete related rows (quote items) from sales_flat_quote_item table through foreign key constraint.

  • 2
    Please don't add 2 answers if they are not needed. You can always edit a previous answer and provide additional data. – Marius Dec 18 '14 at 7:55
  • Please don't ever do it this way. – chaoticgeek Dec 24 '14 at 13:59

Below are the list of options and all options are working for my case.



3.$quote = Mage::getSingleton('checkout/session')->getQuote(); 



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

7.$cartHelper = Mage::helper('checkout/cart');
    $items = $cartHelper->getCart()->getItems();       
    foreach ($items as $item)
            $itemId = $item->getItemId();

8.$quote = Mage::getSingleton('checkout/session')->getQuote();
$item = $quote->getItemByProduct($product);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.