You can let the javascript validate the stock against the number of items the user is trying to add to the cart. Just add the stock to the product div as an attribute and you will have access to it when the user clicks add to cart:
If you want more security the JavaScript library have a getStock method so you can fetch it directly from the server.
TeaCommerce.getStock(nodeId, settings)
If you want even more security you can use the .NET eventmodel and validate the stock on the serverside.
Remember that Tea Commerce uses an optimistic stock management model. This means that the stock will be updated only when the user completes a purchase. In theory two users will be able to buy the last stock of an item, at the same time. You should take that into account when writing the shops terms and conditions.
Tea Commerce does not support pessimistic stock handling, but Tea Commerce will automatically decrease the stock when the order is finalized.
That means that you risk to double decrease the stock, if you use the default Tea Commerce stock system.
I would make an ajax check of the stock against the server and let the user know if he's trying to add too many.
Otherwise you could implement your own stock handling, in which case you can decrease the stock whenever you want :)
I'm also very interested in finding out how to solve this challenge. Actually I need to find out how to check the stock on a given variant instead of on the main product. I'd appreciate if you'd share your solution if you got it working. Thanks.
Checking a variants stock is no more dificult than checking the main product stock. By using the getStock method from the JavaScript or maybe it's xslt library sister GetStock, you can check the stock at any time in the process.
You can even choose to check it before calling goToPayment() and alert the user, if his/her products exceed the available stock. You can do this in your javascript, but you could also choose to do it in the Tea Commerce .NET event hooks if you want even more security.
Topic author was deleted
Stock
Hi,
Is their a way to check if a new order of products is more then their is in stock?
example: of product A their are 20 in stock but client buys 22 peices. In the starter kit their isn't any check on this!
Thnx,
Bart
Hi Bart,
You can let the javascript validate the stock against the number of items the user is trying to add to the cart. Just add the stock to the product div as an attribute and you will have access to it when the user clicks add to cart:
If you want more security the JavaScript library have a getStock method so you can fetch it directly from the server.
If you want even more security you can use the .NET eventmodel and validate the stock on the serverside.
Remember that Tea Commerce uses an optimistic stock management model. This means that the stock will be updated only when the user completes a purchase. In theory two users will be able to buy the last stock of an item, at the same time. You should take that into account when writing the shops terms and conditions.
I hope that answers your question.
/Rune
Hi Rune,
What solution would you suggest for that? We don't want users to add the last stock of a product at the same time.
We are thinking of decrementing the stock of a product once a user added it to their cart. Do you think that is a good solution?
Thanks
Tea Commerce does not support pessimistic stock handling, but Tea Commerce will automatically decrease the stock when the order is finalized. That means that you risk to double decrease the stock, if you use the default Tea Commerce stock system.
I would make an ajax check of the stock against the server and let the user know if he's trying to add too many.
Otherwise you could implement your own stock handling, in which case you can decrease the stock whenever you want :)
Comment author was deleted
Hi Rune,
Thanks for the reply. I will try these.
Bart
Hi Bart
Got it working?
Hello Bart.
I'm also very interested in finding out how to solve this challenge. Actually I need to find out how to check the stock on a given variant instead of on the main product. I'd appreciate if you'd share your solution if you got it working. Thanks.
/Søren
Hi Søren,
Checking a variants stock is no more dificult than checking the main product stock. By using the getStock method from the JavaScript or maybe it's xslt library sister GetStock, you can check the stock at any time in the process.
You can even choose to check it before calling goToPayment() and alert the user, if his/her products exceed the available stock. You can do this in your javascript, but you could also choose to do it in the Tea Commerce .NET event hooks if you want even more security.
/Rune
is working on a reply...