If you ever need to programmatically clear Magento’s shopping cart, use the snippet of code below. If you need to clear the user’s entire session, including the shopping cart, shipping information, billing information and chosen payment methods, please refer to the snippet further below.
Clear shopping cart
foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){ Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save(); }
Clear entire session
Mage::getSingleton(‘checkout/session’)->clear();
Happy coding!





Sep 09
“Clear shopping cart” works perfectly.
Thx!
Jun 10
What page should we update in order to get this working correctly? I figured out how to do it by modifying core code but was thinking someone was able to do it by modifying a design file.
Jun 10
Shouldn’t do “Mage::getSingleton(‘checkout/cart’)->truncate();”
the same?