Magento has two ways to store a cart. Logged In users can have cart saving defined for as long as you want to define it and it is stored in the database tied to the user number. Non-logged in users seem to be bound by how long your site keeps it's session variables. This leads me to 2 questions.
1) Am I correct in thinking that non-logged in users carts are tied to session timeouts?
2) Since Magento/Varien recommends fairly short times for killing session variables (usually only 4 hours), if question one is true, is there a way to keep a non-logged in cart around without changing the session time out variable?
Click on the shopping cart icon at the top right, and then select View Full Shopping Cart at the bottom of the menu. Once you are in the cart, you will see 4 buttons at the bottom of your list of items. The one on the right is Save This Cart. Pick a name for the cart and save it.
A shopping cart enables the buyers to track their progress on an online shop or view the existing items from the same page. With Magento, you can easily configure various kinds of shopping carts that display different information to the customers and maintain a better shopping experience.
$_product = $this->product->load($productId); $this->cart->addProduct($_product, $params); $this->cart->save(); You can even use or customize this code as per your need to add more additional or custom options as well as configurable product code.
As I understand it carts are saved as quotes, even for guests. Logged in users have a customer ID which is stored with the quote, guests do not so their quote has a null customer ID, hence you may find a store has a lot of orphaned/incomplete quotes in the DB. The only way to associate a guest with their cart is by storing the quote ID in their session.
You could extend how long their quote is available to them by storing the quote ID directly in their cookie with a long timeout but this leads to an obvious security breach; anyone could adjust the value in their cookie and view anyone else's cart.
The only safe way is to proceed is to create a table of guest tokens and associate it with quotes (sorry no code this time, there's too much to explain in a low level). The token is the only public part and is set in the cookie. Tokens should be random and long, say 512-bits/64-chars, but not too long because they are included in every HTTP header. Every time a new session is created it might be a returning guest so check for a token and look it up in the table. Take the found quote ID and store that in the session thereby resurrecting the old cart. Quotes with customer IDs don't need to be rescued this way so should be exempt, especially since a logging-out customer doesn't want to see any part of their account remain visible.
Take a look into your magento database at the table "sales_flat_quote"
Regards boti
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With