How can I discount an inventory item?

Good morning, I need your help, I have a Marketplace application, and I need that when the user completes the purchase, what he bought is discounted from the inventory after he clicks on the “Confirm Order” button at the same time that the button sends the information by WhatsApp

Hello, welcome to Glide’s community forum :wave:

Is your marketplace application built with Glide? Building a marketplace on Glide can be done, but it’s not necessarily a tool appropriate for an e-commerce or marketplace use case.

I would approach it like this.

Recording Transactions:

  1. Create two tables:
  • Orders table
  • Line Items table
  1. Add a boolean field in the Orders table to indicate if an order has been processed.

Calculating Inventory:

  1. In the Line Items table:
  • Create a relation to the Orders table
  • Add a lookup field to access the boolean from the Orders table
  1. In the Inventory table:
  • Create a query that links to the Line Items table
  • Filter the query to show only sold items (using the boolean)
  • Use a rollup to calculate the total number of items sold
  • Subtract the total sold from the initial inventory to get the current stock
1 Like