Combining Quantities for Items in a Shopping Cart with Repeating Group

Hello everyone,

I hope you’re all doing well. I am currently working on a shopping cart feature where users can add items with specific quantities and urgency levels. These items are then displayed in a “Pending” repeating group.

Here’s the functionality I’m trying to achieve:

  1. When a user adds an item with a certain quantity (e.g., Item A with quantity 25), it gets added to the “Pending” repeating group.
  2. If the user then decides to add the same item again with a different quantity (e.g., Item A with quantity 30) while the initial request is still pending, I want the system to recognize that there is already a pending request for that item.
  3. Instead of creating a new entry in the “Pending” repeating group, the system should update the existing request by adding the quantity of the new request to the existing one (in this case, the quantity would become 55).

I am struggling with how to implement this logic . Could anyone provide guidance or examples on how to achieve this?

Thank you in advance ! :slight_smile:

Hello @simonnlef If you have already prepared a DB structure for your app can you share a screenshot of it.
Otherwise u’ll need to a pending data type (DT) which will have fields like
“Item” linked to Item DT,
and of course a unique id for each pending item
and so on…
so when a user add another Item u’ll “Do a search for the item in “Pending” DT”, If an entry is found (i.e., the item is already pending), trigger an “Update thing” workflow to update the existing entry. Otherwise, create a new entry in the “Pending” repeating group.
Now u’ll trigger another workflow “make changes” using a “math expression plugin” or any other means to add the initial value and the current one. then also update the “pending” DT with the current value of that particular item…

There’ll surely be a better way to do this, but this is my opinion.
Goodluck

hi @geesonofgee ,
I’m having trouble understanding the explanation provided. I can’t seem to apply it correctly. Could you please help me understand it better? I’ve attached some photos to my post. Could you explain it to me in more detail based on these images?

Thank you in advance!
:slight_smile:



I can give you 15-30min call if you don’t mind. it seems your apps not in English, I hope we’ll understand each other My Calendly. You can book a call tomorrow if that’s not too far

Hey Simon.
Here’s a different approach to make this happen.

When the user add something to the cart, create a database entry like below:

Database Thing: Cart Entry
With the following fields:

  • Item : This is your item that is being added to the cart
  • Quantity : This is a number of how many items to add to the cart

Then in your RG, you can show the list of Cart Entry.

Now if you add the same items as you describe, what happens? You will indeed get 2 different entries. That’s annoying.
To fix this, when you’re clicking on the button to add to the cart, you need to split into two workflows:

Scenario 1

If there is no other similar items in the cart, then, create a cart entry.

For this, you would search if you can find any other Cart Entry with the same item (Do a search for Cart Entry where Item = Your item)
If the first item is empty, this means you need to create the Cart Entry, so you can proceed with the workflow we described above.

Scenario 2

There is already a similar item in the cart, then, add the quantity.

For this, you would search if you can find any other Cart Entry with the same item (Do a search for Cart Entry where Item = Your item)
If the first item is not empty, this means you need to update the quantity only.
So in your workflow actions, you will Make change on a thing (the thing you’re changing is the Cart Entry that has your item, same as the one from the conditional) and change the Quantity field by This Cart Entry' Quantity + X

Hope this helps <3

1 Like