Magento clear cart session


Magento clear cart session : Sometimes we need to clear cart’s session data programmatically. In this tutorial we are going to explain how to clear cart session programmatically.


Magento clear cart session

If you want to clear the entire cart session, shopping cart, shipping information, billing information and payment methods use the below method-

Clear Shopping Cart

Magento clear cart session:

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

Clear Entire Checkout Session

Clear Entire Checkout Session:

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

The above code will remove the entire session.


User Ans/Comments

📖 Read More


Advertisements