I want to add some custom data to persistent shopping cart like below:

Assume:

  • Persistent shopping cart enabled
  • Session timeout set to idealy amount of time (eg: 1 week, 1 month)

Scenario (desired):

  1. Visitor visits website (not logged, doesn't add anything to cart)
  2. Prompt visitor to input some custom data (eg: body height, body weight, ...)
  3. Visitor inputs data then click Save
  4. Website saves this data to persistent shopping cart
  5. Several days later, visitor visits website again and this data remains on website, no need to re-input anymore.

How can I do that? When visitor hasn't added anything to shopping cart, is it possible to add custom data to cart? Where to add? Quote or something else?

P/s: I want to add custom data to persisten shopping cart because it seems like the most reliable solution I've known.

up vote 2 down vote accepted

I did a little check on the persistent functionality and where the data goes. But as far as i can see the persistent row only gets created when a user logs in. But a sessions is made also for guests. If you want to register guest data i think you should use session. Example for get and set:

Mage::getModel("customer/session")->setData("weight","100");
Mage::getModel("customer/session")->getData("weight");

If you want to prompt a visitor to somewhere based on a condition you could use an event observer. For the form you'll need some custom frontend module. There's loads of tutorials, guides and even generators out there to help you with that.

If you really need the persistent cart feature for this i suggest that you store this information as customer data so it never disappears, if you want that to happen ofcourse.

These are my thoughts, it is untested but i think this is a good starting point. If you require more help just let me know. Goodluck!

  • Yes, I need a solution rather than details code. Thank you for your answer. I'll give a try now then get back later. – Tran Dinh Khanh Jul 12 '15 at 4:36

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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