# How to add the number of unit for each item and the "out of stock" message for my e-commerce app

**URL:** <https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113>\
**Category:** Ask for Help\
**Created:** [May 18, 2022, 12:46pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113 "2022-05-18T12:46:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Nougue](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/m_nougue/32/42816_2.png) [@M\_Nougue](https://community.glideapps.com/u/M_Nougue)\
**Post date:** [May 18, 2022, 12:46pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/1 "2022-05-18T12:46:51Z")

</div>

Hi all,

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,  
Regards,

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [May 18, 2022, 2:16pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/2 "2022-05-18T14:16:10Z")

</div>

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

In Glide…

1. When someone claims/buys a product, add a new row to a new table called “Purchases” (or the like)

2. Create a relation column (match multiple) in the “Items” table that matches the Row ID with the Item ID column in the “Purchases” table

3. 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)

4. 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.

5. 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`.

I do something similar here:  
https://www.youtube.com/embed/Vl7RmkNe-D0?feature=oembed&wmode=opaque&list=PLiXRc87c6KKXcnnsS3ZKmyLyqiSFjuuNv

---

<div class="post-metadata">

**Author:** ![M\_Nougue](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/m_nougue/32/42816_2.png) [@M\_Nougue](https://community.glideapps.com/u/M_Nougue)\
**Post date:** [May 18, 2022, 4:44pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/3 "2022-05-18T16:44:40Z")

</div>

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 ?

Thank you so much for your precious help

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [May 18, 2022, 4:57pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/4 "2022-05-18T16:57:16Z")

</div>

If you’re using a form to write the new row to the purchases sheet, you can pass the RowID automatically by using Screen Columns.

The UI is outdated in the video, but the process is identical:

[![](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/b/0b49756af48c908a53a7e47f0cbf2c0457d0de6b.jpeg "Working with Column Values - Glide Tutorial") ](https://www.youtube.com/watch?v=2XEf6BVYciA)

---

<div class="post-metadata">

**Author:** ![M\_Nougue](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/m_nougue/32/42816_2.png) [@M\_Nougue](https://community.glideapps.com/u/M_Nougue)\
**Post date:** [May 18, 2022, 5:35pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/5 "2022-05-18T17:35:55Z")

</div>

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).

Thanks again for your help,

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [May 18, 2022, 5:57pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/6 "2022-05-18T17:57:29Z")

</div>

Ah…you’re using the Buy Button…yeah, it’s a bit trickier then. Are you using Google Sheets or Glide Tables?

---

<div class="post-metadata">

**Author:** ![M\_Nougue](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/m_nougue/32/42816_2.png) [@M\_Nougue](https://community.glideapps.com/u/M_Nougue)\
**Post date:** [May 19, 2022, 5:17am UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/7 "2022-05-19T05:17:42Z")

</div>

Google Sheets !

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 19, 2022, 2:08pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/8 "2022-05-19T14:08:28Z")

</div>

Do you see an “App: Sales” sheet in your spreadsheet?

---

<div class="post-metadata">

**Author:** ![M\_Nougue](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/m_nougue/32/42816_2.png) [@M\_Nougue](https://community.glideapps.com/u/M_Nougue)\
**Post date:** [May 19, 2022, 2:59pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/9 "2022-05-19T14:59:01Z")

</div>

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 !!!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 19, 2022, 11:20pm UTC](https://community.glideapps.com/t/how-to-add-the-number-of-unit-for-each-item-and-the-out-of-stock-message-for-my-e-commerce-app/42113/10 "2022-05-19T23:20:10Z")

</div>

> [@M\_Nougue](#):
>
> 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’m not sure you have gone past that step yet or not, but you must create a “mirror” sheet by using a formula to make Glide see the “App: Sales” sheet.

> [@Can't find sales in sheet?](https://community.glideapps.com/t/cant-find-sales-in-sheet/26556/2):
>
> hey @willem In your spreadsheets you’ll see a hiden sheet called App:Sales, use the formula ={'App: Sales'!A:Z} in a new sheet to duplicate the data and make it accessible through the app.
