0

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?

  • Is that a copy paste of your code, or a manual type out? $quote->save(); is missing the brackets to call the function as opposed to accessing a public member. – Peter O'Callaghan Dec 18 '13 at 22:27
  • thank you! I've missed the brackets, now it works like a charm! – satboy78 Dec 19 '13 at 9:35
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.