Magento: How to remove specific product from cart

Sometimes we want to remove specific item from cart, if we already have in it, let see below how we can do that.

$cart = Mage::helper('checkout/cart'); // cart object

$productId = 1234; // productId you want to remove
$quote = Mage::getModel('checkout/cart')->getQuote();
foreach($quote->getAllVisibleItems() as $item) {
$itemId = $item->getItemId();
$proIdExist = $item->getProduct()->getId();
if($proIdExist == $productId) {

Leave a Reply

Your email address will not be published. Required fields are marked *