Skip to content

Magento: Clear Everything in The Cart

this is the way how to clear everything in the cart, clear the items & cart session,

$cartHelper = Mage::helper(‘checkout/cart’);

$items = $cartHelper->getCart()->getItems();

foreach ($items as $item) {
$itemId = $item->getItemId();

$cartHelper->getCart()->removeItem($itemId)->save();
}

Mage::getSingleton(‘checkout/session’)->clear();
Mage::getSingleton(‘checkout/cart’)->truncate();

Maknyos!!!

Share