开发者

Ajax shopping basket - best practices

When developing an ajax based shopping basket for an ecommerce site what are some of the best practices?

Im interested in all best practices but i am particularly interested in how stock levels a开发者_JAVA技巧re managed. By this i mean say a customer goes to a product screen then at page load i would assume that they cannot put more than is available in stock in to their basket. Say though they add 2 items of that product into their basket then should this temporarliy reduce the stock levels throughout the site for any other customer or should all of this be handled at the checkout?


I would say soft compare it first - don't allow them to add more than what's in stock to their cart (just so they know at most how many they can get). Then at checkout do a hard compare - if the requested quantity is more than what's in stock at this point (someones purchased while they were still shopping, or whatever) don't let them continue. You don't want to hold up inventory in hopes that someone else will end up purchasing.


Regarding the stock portion of your question: I would handling everything at checkout. If someone hasn't paid for the product (or put down some money), then they shouldn't be able to restrict someone else from buying it.

If you handle this in Javascript when they put it in their cart, someone could basically do a denial of service attack by putting everything in their cart so that nobody could purchase your products.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜