$session= Mage::getSingleton('checkout/session');
$quote = $session->getQuote();
$cart = Mage::getModel('checkout/cart');
$cartItems = $cart->getItems();
foreach ($cartItems as $item)
{
$quote->removeItem($item->getId())->save();
}
By writing the above code your all cart item will be delete.If you wish to delete a particular product from the cart session then instead of writing $item->getId() pass your Id of the product.
for example
foreach ($cartItems as $item)
{
if($item->getId()== 2)
{
$quote->removeItem($item->getId())->save();
}
}
Hope it Helps... Thanks...


No comments:
Post a Comment