This is the blog for getting Idea regarding PHP, Magento, jQuery and JavaScript for Customization.

Saturday 28 July 2012

Magento : Programatically remove product form cart


<?php
$session= Mage::getSingleton('checkout/session');
$quote = $session->getQuote();

$cart = Mage::getModel('checkout/cart');
$cartItems = $cart->getItems();
foreach ($cartItems as $item)
{
    if($item->getProductId()== 4)
    {
        $quote->removeItem($item->getId())->save();
    }
}
?>

No comments:

Post a Comment