Magento 1.9 – How to Start New Quote Session After Completing Order Programmatically

magento-1.9ordersquote

I am trying to create order programmatically by extending Mage::app() into my external folder.

I can able to create an order successfully. But after creating an order my quote is not getting expired. Next order is also created with same quote_id.

To avoid this I tried below,

            $order->sendNewOrderEmail();

            $quote->setIsActive(0);
            $quote->save();

But this remove the whole record from sales_flat_quote table.

How can I start next order with new quote?

Best Answer

You can change in session like below.

Mage::getSingleton('checkout/session')->setQuoteId(null);

so now if you will try to create new order then it will not find quote id in session. so magento will create new quote for your next order.

Hope it helps.