How To Aggregate Duplicate Items?

Page 1: The user enters the number of products they’d like to buy
Page 2: They are shown a repeating group with dropdowns with auto-binding enabled to select which products they’d like.

Problem: Say the user chooses 3 products and then chooses Product A, Product A, and Product B. When they press a continue button, I’d like to do 2 things:

  1. Increase the quantity of the first instance of Product A to 2.
  2. Delete the second instance of Product B.

What would be the best way to do this?

I should mention that it’s important to do this because of the Stripe integration not allowing duplicate plans for a subscription.
bubbleissue pt 1 bubbleissue pt 2

In the images above, the final result in the user’s cart should be:

  • Qty: 2 ; Size: 10 x 10
  • Qty: 1 ; Size: 12 x 12

Currently, it is:

  • Qty: 1 ; Size: 10 x 10
  • Qty: 1 ; Size: 10 x 10
  • Qty: 1 ; Size: 12 x 12

Just curious… Is there a reason the user is not allowed to first choose the products they’re interested in and then specify the quantity of each?

Yes, it’s just a simpler ordering experience for my use case. It’s a single product with a single variation which is size. I’d rather not have the customer have to deal with sizes and quantities on the same screen. I could certainly change to what you suggested, but really the only reason I’m using Bubble as opposed to Shopify is that I want this very specific ordering process.

Got it. A couple follow-up questions…

  • Is the user limited to purchasing no more than 4 products at a time?
  • How many different sizes are there?
  • Yes, they are limited to 4
  • There are about 25 sizes

For 1, it seems you just need to leverage the “group by” and “aggregate” functionality.

For 2, you just need to “delete a thing” from the DB, no?

That said, I’d probably take a different approach and create only the items needed but also provide the ability to add or remove items individually.

In the following example, I arbitrarily chose to allow purchasing of up to 7 products at a time (instead of 4), and there are 25 different sizes…

The icon in the upper right takes you to edit mode.

1 Like