Created
July 8, 2014 12:40
-
-
Save alihalabyah/4d39106eaa8fe48b481d to your computer and use it in GitHub Desktop.
Clear Magento cart and quote items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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