I’m trying to build my first app on glide to sell some second hand products
I have one unit per product for the moment and I would like to make sure the same product will not be sold twice ! So here are my question:
1 - How can i link the number of units for each product ?
2 - How can i make sure to add the message “out of stock” when the product is sold?
(My data is extracted from a google sheet)
Thanks in advance so so so much for your support!!!
You’d save my day,
I imagine you have a table/spreadsheet of available items. Let’s call this table “Items”.
Add a RowID column to this table that will serve as the “Item ID”
Add a number column to this table called “Quantity”. Since you said there is only one unit per item, you’d write the value 1 for each item
When someone claims/buys a product, add a new row to a new table called “Purchases” (or the like)
When this row is added, be sure to pass along the Item ID (I recommend using Row ID in the “Items” table)
Create a relation column (match multiple) in the “Items” table that matches the Row ID with the Item ID column in the “Purchases” table
Create a rollup column (let’s title it “purchaseCount”) in the “Items” table that’s sourced from the multiple relation in step 2. This will give a count of how many times that item was purchased (how many rows for that item are in the “Purchases” table)
Create a math column in the “Items” table (let’s title it “remaining”) that subtracts purchaseCount from Quantity. This will result in the number of items remaining for purchase.
On the Details screen for each item, add visibility logic to components to prevent the user from purchasing the item when "remaining" is less than 1.
Add this condition to a hint text component to show a message that this item is “out of stock”
Add the reverse condition ("remaining" is greater than 0) to the button they use to purchase the item.
Wow…thank you so much for your help !!! I did all the set up you suggested and it works. Amazing :).
I have one (last) additional question: Is it possible to make sure the Item ID will be automatically added in the table “Purchases” as soon as someone will buy a product? - or do i need do it manually as soon as a purchase is done ?
Thanks for your quick reply ! I tried to follow the video but i don’t have the ability to put a destination sheet with the buy button as shown for the form button in the video. I only get the product info (i have the starter project subscription).
Yes, thank you!
Indeed, I found out that the Item ID was appearing in the “App: Sales” and created the relation column and the rollup column with the instructions quoted below.
I am now able to see when a product is out of stock on my app or not.
Thank you both !!!