Php – magento shopping cart does not get clear

magentoPHP

I am developing an application in magento. I have 3 step checkout using onepage checkout. 1.Billing information 2. payment Info 3. Order review. Shipping information is merged with billing information. When I place an order shopping cart does not get clear. How to clear shopping cart after placing order successfully. but when I put this piece of code.

foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item )
{
        Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save();

}

shopping cart gets clear but user automatically gets redirected from order summary to cart page.

I need to empty cart in savePaymentAction() in OnpageController.php
Can anyone please guide me. how to fix this?

Best Answer

Below are two solutions:

Answer 1: Mage::getSingleton('checkout/session')->clear();

Answer 2: Mage::getSingleton('checkout/cart')->truncate();

Related Topic