Shopping cart abandonment [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
开发者_如何学运维 Improve this questionHow would you monitor shopping cart abandonment? Would you use session variable with time and if certain seconds have elapsed, regard as abandonment?
How would you do this?
I would use a cookie to store an identifier. The identifier then has an entry in a database containing the contents of their cart.
You could then set the cookie to expire in how many hours or days you want, say 10 days. At the same time, you could then use a cron job to clean out entries in the database that are older than 10 days and are classed as expired.
I would like to use a Session system as you said. But if you want to make a more professional system, in my opinion, you have to store in a temp table the cart and let the user decide IF and WHEN to drop the cart. Using this temp table you let the users to logout and login whenever they want and to keep the items in the cart.
We use redis as shopping cart we store a hash with the key "user_id.cart" and set an expiration time (redis removes the data automatically when the time is up). The structure looks like:
user_id.cart = { item_id1: amount1, item_id2: amount2, ...}
php module: https://github.com/nrk/predis
in a recent project we decided to treat a cart as an order with a status as "cart". This made transitioning from "cart" to a processed or shipped order very easy. It also gives us great insight into what was in the cart before abandonment. The downside is that its in the database, which is much slower than Redis or some other memory-based key-value store method. We also need to cleanse the database periodically to keep the table indexes smaller.
精彩评论