Skip to content

Instantly share code, notes, and snippets.

@alihalabyah
Created July 8, 2014 12:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alihalabyah/4d39106eaa8fe48b481d to your computer and use it in GitHub Desktop.
Save alihalabyah/4d39106eaa8fe48b481d to your computer and use it in GitHub Desktop.
Clear Magento cart and quote items
<?php
// Clear Magento cart and quote items
$cart = Mage::getModel('checkout/cart');
$cart->truncate()->save(); // remove all active items in cart page
$cart->init();
$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();
}
Mage::getSingleton('checkout/session')->clear();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment