简体   繁体   English

ASP.NET,C#:如何处理购物车问题

[英]ASP.NET,C# :How to handle Shopping cart Problem

I am developing an e-commerce project, in this I have one crucial product that have only one ProductQuantity,and that product have quantity 1 so two person can not buy that product. 我正在开发一个电子商务项目,在这个项目中,我有一个关键产品,只有一个ProductQuantity,并且该产品的数量为1,所以两个人无法购买该产品。 at the time of AddToCart I have reduced the quantity from the database. 在AddToCart时,我减少了数据库中的数量。 I have test this with 10 machine and at the same time all 10 machine click on the AddToCart Button,but 3 machine is able to add the same product to own cart, which is wrong, only one machine(person) can add that product. 我已经用10台机器测试了这一点,同时所有10台机器都单击了AddToCart按钮,但是3台机器可以将同一产品添加到自己的购物车中,这是错误的,只有一台机器(人)可以添加该产品。

Please suggest me how to handle this scenario. 请建议我如何处理这种情况。

Thanks Vijendra 谢谢维真德拉

When you add to cart, you shouldn't really be removing one from the ProductQuantity, it should stay as is. 当您添加到购物车时,您实际上不应该从ProductQuantity中删除一个商品,而是应该保持原样。 Only when the order has been paid for do you drop it from the quantity. 仅当订单付款后,您才从数量中删除该订单。

Otherwise you end up with the scenario of someone coming to the site, adding a bunch of stuff to the cart, then leaving and never coming back, now all your products are 1 less in stock even tho your inventory would be 1 greater than ProductQuantity. 否则,您会遇到这样的情况:有人来该站点,向购物车中添加一堆东西,然后离开,再也不会回来。现在,即使您的库存比ProductQuantity大1,所有产品的库存也少1。

The products can display something like 'low in stock' or 'less than 5 available'. 这些产品可以显示类似“库存不足”或“少于5个可用商品”的信息。 The end user knows there isn't many left, then when you get to the checkout, you can confirm the quantity to ensure it hasn't been sold prior while the user was fluffing around. 最终用户知道库存不多,那么当您结帐时,您可以确认数量以确保在用户四处游走时尚未售出。 If the product is now out of stock, then display a message saying it's no longer in stock. 如果该产品现在无货,则显示一条消息,指出该产品不再有货。

The flipside of the coin here is, it's going to be rare for you to have a scenario where this actually occurs, unless your site is really popular. 硬币的另一面是,除非您的网站非常受欢迎,否则您很少会遇到这种情况。


Edit: Additional answer to address 'I want 10 people' comment 编辑: 解决“我想要10个人”评论的其他答案

If you say you want 10 people to try add it, with only 1 person to successfully add it, then you are doing yourself out of business. 如果您说要10个人尝试添加它,而只有1个人成功添加它,那么您将自己倒闭了。

If User A add's the product to the cart, User B cannot. 如果用户A将产品添加到购物车,则用户B不能。

User B leaves the site looking for where he can buy the product. 用户B离开站点,寻找可以在哪里购买产品。

User A then leaves cos he decided he no longer wants the product, the product is now back in the database, and you have lost a potential sale. 然后,用户A离开cos,他决定不再使用该产品,该产品现在又回到数据库中,并且您失去了潜在的销售机会。

After the first time that "Add To Cart" is clicked, have you checked the database to verify that the count has indeed reduced to 0? 第一次单击“添加到购物车”后,是否检查数据库以确认计数确实减少到0?

Secondly, once the count is at 0, have you verified that additional clicks to "Add to Cart" check the quantity field to make sure that there is sufficient quantity to fill their order? 其次,一旦计数为0,您是否已验证是否有其他点击“添加到购物车”,请检查数量字段,以确保有足够的数量来填充其订单?

I suspect that the problem is with one or the other of these two areas... 我怀疑问题出在这两个领域中的一个...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM