Question

I need to save quoteId and unset quote (cart) data in session clicking a button when I'm is in the cart, then after performing other operations (for example, I buy some items) I would like to click another button and restore previous cart using quoteId.

I've correctly got quoteId from session using Mage::getSingleton('checkout/session')->getQuoteId();

Then I've tried to unset quote using

$quote = Mage::getModel('sales/quote')->load($quoteId);
$quote->setIsActive(false); //tried setIsActive(0) too
$quote->save();
Mage::getSingleton('checkout/session')->setQuoteId(null);

but unfortunately I still have a filled cart, in fact if I change page and then I come back to my cart I can see it (I expect that it will be empty after unset...), and on my database I can see is_active = 1 for this quote.

What I've done wrong? Can you please help me figuring out how to solve this issue?

Then, do you know how to load/restore quote from database and set it in session, so I can see it in frontend cart?

Was it helpful?

Solution

I'm adding this as an answer for the sake of completeness...

You are missing the brackets for the function call to sale. $quote->save(); is missing the brackets to call the function as opposed to accessing a public member.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top