How to stop 2 users from buying the same unique product

I have a RG showing 3 different products. Each of these products is only available once in our inventory. From the client side, to buy one of these products, they need to click on “buy now” button in the RG cell, then a confirmation popup appears and they need to click “yes”.
When “Yes” is clicked, this product disappears from the RG that now only shows the 2 other products.

Problem: user A clicks on “buy now” and is now in the confirmation popup thinking for 1 minute. user B clicks on “buy now” 10 seconds after user B and are now both in confirmation popup. Now both of them can purchase this same item that is only available once. How can I avoid this?

If I disable the button “buy now” as soon as any first user clicks it, I would face the problem that User A can idle for 10 hours in the confirmation popup and miss up on other buyers.

Thanks !

Hi there, @btinc… if I understand your post correctly, you don’t want the act of clicking the “buy now” button to cause the product to become unavailable because the user still has to confirm that they actually want to buy it (which makes sense). So, I could easily be missing something, but couldn’t you add a check on the confirmation popup’s “yes” button that checks to see if the product is still available when that button is clicked? Then, it wouldn’t matter how many users click the “buy now” button because the first click of the “yes” button on the popup would cause the product to become unavailable, and any subsequent click of the “yes” button by any user who was also considering buying the product could trigger a message saying the product is no longer available.

Any of that make sense and sound like it could work for you?


1 Like

Hello @mikeloc !
You understood perfectly what I need. As a noob in Bubble, I’m struggling to achieve what you just described, especially the “add a check on the confirmation popup’s “yes” button that checks to see if the product is still available when that button is clicked” .
I’ve been trying for 3 days with states (when button “Yes confirm” is clicked, make changes to current item’s “available” to “Not available”), but for some reason, when User A confirms “Yes” and User B is already in the popup, it seems like the workflow is disregarding the updated state by User A, and allows user B to buy the same product.
If you have a simpler way to rig this or a video that can show it, it would be great

I’m not sure what you mean when you say you have been trying with states… if you mean custom states, that’s probably not the way to go here.

If you are setting a field in the database when the “yes” button is clicked that denotes the product as no longer available, then it seems like you could put a condition on the “yes” button that checks the field, and if it is already in the not available state, show an alert/message instead of proceeding with the buying workflow. Can you share some screenshots of your setup?

1 Like

Thanks a lot for your help @mikeloc , the problem was that I was passing the data from the RG to my popup via states, and as you told me, I now am passing them directly via data types.

1 Like