tags:

views:

34

answers:

2

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 are 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?

+2  A: 

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.

bradenkeith
A: 

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.

Topher Fangio