PHP:同时购买可以节省 50 美元?
好的,我的客户想要在购物车中显示“同时购买”功能,如果他们在购物车中有 1 种特定的商品类型,他们希望它显示另一种特定的商品类型,这样如果他们同时购买这两种商品,就可以在总额中节省 50 美元。 我正在尝试思考什么是最好的设置方法,这样它就不会轻易被黑客攻击(即:将两者添加到购物车,然后删除一个并保留折扣)
理论上有人有一些一般想法吗?
谢谢。
OK my client wants to show a buy both feature in the cart, if they have 1 particular item type in the cart they want it to show up for another particular item type so if they buy both they can save $50 off the total. I am trying to wrap my head around what would be the best way to set this up so it couldn't be easily hacked (ie: adding both to the cart then removing one and keeping the discount)
does anyone have some general ideas in theory?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
为什么不在提交订单之前进行检查? 这样,每次他们进入提交订单页面时,它都会检查这两个项目是否都存在。
Why not perform the check right before they submit the order? that way, everytime they get to the submit order page, it will check if both items are present.
足够简单 - 始终根据当前购物车内容即时计算最终价格。 您提到的问题似乎只有在您计算最终价格并以某种方式缓存时才会出现问题。
easy enough - always calculate the final price on the fly based on the current cart contents. The issue you mention seems like it would only be a problem if you were calculating the final price and caching it somehow.
通常它是通过创建一个新的捆绑包项目来完成的。 虽然有点脏但是很管用:)
usualy it'd done by creating a new bundle item. It's a bit dirty but works :)
他们是否已经在使用系统,或者这是您的自定义作业?
Are they using a system already, or is this a custom job on your part?
将折扣添加到购物车并使用另一个表来跟踪折扣的依赖项。 每当从购物车中删除商品时,请检查以确保折扣仍然有效。 如果是的话,那就太好了。 如果没有,请将其删除并重新计算购物车价格。
Add the discount to the cart and use another table to keep track of the discount's dependencies. Whenever an item is removed from the cart, check to make sure the discount is still valid. If it is, great. If not, remove it and recalculate the cart price.