电子商务网站中的购物车 [英] Shopping cart in e-commerce website

查看:102
本文介绍了电子商务网站中的购物车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在为我的项目创建一个电子商务网站.我完成了大部分内容,但对一个主题感到困惑.如何保存用户当前的购物车数据?


我认为,如果我在数据库中创建了一个表,并且购物车中的商品一直保存在该表中,直到订单完成.然后,我可以从购物车表格中删除该商品.在这种情况下,如果用户在不下订单的情况下退出并稍后进入站点,则他的购物车不会丢失,并且会继续购物.


这是一种好的编程方式(我是说有效的)还是应该使用类似memcache的东西?

谢谢,

Hi,

I am creating an e-commerce website for my project. I completed most of it, but confused about one topic. How can I keep current shopping-cart data of user?


I think that if I created a table in database and shopping cart items are kept in that table until order finishes. Then, I can delete that item from the shopping cart table. In this case, if the user quits without giving order and enters the site later, his shopping cart will not be lost and he will continue his shopping.


Is this a good programming way(I mean efficent) or should I use something like memcache?

Thanks,

推荐答案

通常的方法是将其保存在数据库中-在这种情况下,您将必须进行常规检查以清除"旧的冗余数据或Cookie(在这种情况下,它们位于用户PC上,可以设置为在一段时间后自然过期),例如一周或一个月.

我个人使用cookie-将数据保存在用户PC上.
The normal ways are to either keep it in a database - in which case you will have to do regular checks to "sweep out" old, redundant data, or in cookies - in which case they sit on the user PC and can be set to expire naturally after a period of time - a week, or a month say.

Personally, I use cookies - it keeps the data with the user PC.


这篇关于电子商务网站中的购物车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆