Hi again! I hope you're having a great day. We ar...
# support
b
Hi again! I hope you're having a great day. We are nearing the completion of our e-commerce website and have come across a fairly standard edge case that we should have detected earlier. I'm particularly interested in understanding how to handle potential conflicts when multiple customers attempt to purchase the same limited stock product. Our current thinking involves implementing (one of) the following strategies: 1. Reserve stock for a limited time and if purchase is not completed, release stock. For the potential edge case that two users still try and checkout simultaneously, use race conditions to allow first user to successfully checkout. 2. Real-Time Inventory Updates: We are exploring options like web sockets or AJAX polling to achieve real-time communication 3. Notifications: Depending upon whether or not we use solution 1 or 2 above, we will use standard notifications regarding the exhaustion of stock. (Likely at checkout). In the case of the real time inventory solutions, we are interested in hearing from anyone that has experience dealing with notifications throughout the shopping experience (for example, using dynamic scarcity measurements, real time notifications on product sliders, list and details pages, etc.). I would greatly appreciate insights from those who have dealt with similar scenarios. What approaches did you take to manage limited stock effectively? I'm open to alternative solutions or any advice you can provide. Thanks! Best regards, Ben
👀 1
k
Hello! I was under the impression that this is already covered with Solidus. We allow multiple users to add to cart at simultaneously the product with limited stock, but before the order completion, there’s a check that avoid the checkout to be completed if there are no more enough stocks for the items in the cart. See: • https://github.com/solidusio/solidus/blob/9b11dc7d18629ae20cd29d9194442f7295d47b5d/core/lib/spree/core/state_machines/order.rb#LL117C53-L117C75 • https://github.com/solidusio/solidus/blob/9b11dc7d18629ae20cd29d9194442f7295d47b5d/core/app/models/spree/order.rb#L778
b
@kennyadsl Thanks for your response and for pointing out the built-in functionality; we have made some modifications to deal with our FEFO inventory; however, I believe that we can muddle our way through and get this to fire as it should. Thanks for your support.
@Sean Denny (he/him) Are you aware of any code that reserves the stock in conjunction with Solidus' built in functionality that @kennyadsl outlined above?