From magento cart you can delete product by clicking on delete button from cart page , but if you wish to delete any cart item in checkout page or by coding then you have write
$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.
e.g: -
foreach ($cartItems as $item)
{
if($item->getId()== 2)
{
$quote->removeItem($item->getId())->save();
}
}
thanks..it helps me..:)
ReplyDeletei which flie i use this code. i want check box option in cart page in magento tell me
ReplyDeleteWhere we want to Paste this code can you please tell me anyone
ReplyDelete