Remove all products from shopping cart in magento

If you want to remove all products from the shopping cart, use the snippet given below.

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

Comments

Popular posts from this blog

Send email from xampp localhost

Modify item price in cart after placing order using sales_quote_add_item

Convert long url to short url using tinyurl api