Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Topic author was deleted

    Aug 10, 2011 @ 21:30

    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

     

  • Rune Grønkjær 1372 posts 3103 karma points
    Aug 11, 2011 @ 08:10
    Rune Grønkjær
    0

    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:

    <div class="product" productId="{@id}" stock="{$stock}">
    

    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.

    I hope that answers your question.

    /Rune

  • George Hipolito 1 post 71 karma points
    Mar 28, 2017 @ 11:07
    George Hipolito
    0

    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

  • Rune Grønkjær 1372 posts 3103 karma points
    Mar 28, 2017 @ 14:21
    Rune Grønkjær
    0

    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

    Aug 16, 2011 @ 09:24

    Hi Rune, 

    Thanks for the reply. I will try these.

    Bart 

     

  • Anders Burla 2560 posts 8256 karma points
    Aug 28, 2011 @ 23:36
    Anders Burla
    0

    Hi Bart

    Got it working?

  • Søren Tidmand 129 posts 366 karma points
    Oct 04, 2011 @ 00:05
    Søren Tidmand
    0

    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

  • Rune Grønkjær 1372 posts 3103 karma points
    Oct 04, 2011 @ 08:07
    Rune Grønkjær
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft