Having duplicate items in a list for users?

I’m building a grocery app, where users click on items in a menu and it gets added to their basket.

But bubble doesn’t allow duplicate items in a list.

Here’s the problem: How do I get it so that when a new user logs in to the store’s app, and adds 2 bread bags, and 3 toothbrushes to their basket? How do I get the user’s basket list to have multiple instances of the same thing ?

1 Like

by making that thing a list

have a look around and spot the checkbox that says “list” and that should do it…then when adding to the basket you need to do a workflow that is change thing

the thing to change is the cart

the field to change is the items

the way to add the item to the list of items is by setting the value to be the “carts value plus item” and then reference the new item

It doesn’t work though.
I have exactly what you’ve said, but in the thing “cart”, where this is the list “items”, if I add more than one instance of the same item, since bubble does not allow duplicates of the same item, it doesn’t get added to the list at all.

I think you may need to consider how you could configure the database…

I haven’t made a shopping cart yet, but I would be soon and with all my projects will do the same thing which is to find online a database scheme or design to follow and tweak to my own needs.

In my mind I would create a database type of shopping cart…then I would have the datafields of product, quantity etc.

I would on the page create a set of custom states to reflect the products and quantities.

At the end of the shopping experience I would transfer all the custom state values to the database of cart…

Again I haven’t made one yet, nor have I looked at a database design online for an e-commerce platform but from what I know about bubble those would be my first thoughts on how to accomplish it because I don’t think having a shopping cart that is just a list of products would be very conducive to adding or subtracting items ( or quantities of items ) or helping with user experience of seeing total costs etc.

It is many-to-many relationship (a cart can have many items, and item can be in many carts) so you will want to build some sort of “link” between them.

So add a data type called “User Cart Item” or whatever.

This has …

Item - type Item
Quantity - number

And you store the list of “User Cart Items” on the user. And when they buy you have the same list on the “Order” thing.

So you only need the “Banana” added once, with a value of 100 … if they are a greedy monkey.

3 Likes

This did not work or I’m doing something incorrectly.

When the user hits the + or add icon on the Banana, what does the workflow do?

Does it add Banana, from the Central Food Menu to the “User Cart Item” and quantity 1 as the 1st item on the list?

The workflow part confuses me…

Yeah.

If we have no Bananas in our cart already … add them, quantity 1.

If we have Bananas in our cart already … +1 on the quantity.

Can knock up a demo if you like ?

Yes, please. That would be extremely helpful!

2 Likes

Thank you so much for doing this!
I fiddled with my app yesterday and actually came up with the same, but yours works so much more efficiently. Thank you again, I really appreciate your help!

Hi @NigelG,

I have question regarding this “Cart” topic, but more on the item’s stock.

3 data types;

  1. Product (field; product name, stock count)
  2. Cart (fields; Product, purchased quantities)
  3. Order (fields; list of Carts)

My scenario is like a normal e-commerce shopping cart, where a customer put multiple products with each product has its own quantities. For example, a customer would like to buy Apple x 5, Orange 2, so they put those in the cart and I created two Cart entry. Now when a customer made payment, I created an Order entry. Next I want to deduct the purchase quantities of each fruit from their respective Product Things’s stock count.

How do I do that, mind sharing with me any ideas? I can’t find a solution to change List of Things to List of Things. Tried so many ways.

Thank you in advance.

It would look something like …

Make Changes to a List of Products

Search for This Order’s List of Carts’s Products : unique items (so a list of all the products in the Order … Apple and Orange in this case)

And then change Stock Count = Stock Count - This order’s cart’s purchased quantities : total - filtered on This Product

1 Like

Thank you for your reply @NigelG

I have tried your method,

  1. first, Make Changes to a List of Products
  2. list to change is Parents group’s Order List Table’s Cart List’s Product ID (Product ID is field name in Cart table, which represent Product).
  3. Field to change is Quantity (which is stock count) = This Product Table’s Quantity - Parent group’s Order List Table’s Cart List:filtered’s Book Quantity (equivalent to product purchased quantities)

I am unable to filter the Cart List’s Product ID

" And then change Stock Count = Stock Count - This order’s cart’s purchased quantities : total - filtered on This Product"

I couldn’t filter Cart List’s Product ID is THIS PRODUCT. (see attached image below)

Nigel, I have managed to get it right based on your idea. Here is the screenshot.

Thank you so much Nigel.

1 Like

Hi Nigel,
I am trying to do something similar, and it does not work for me. The person who logs in is not the buyer but will enter multiple orders on behalf of the buyers.

My data structure is as follows, with some columns omitted for simplicity:
Product
Unique ID (default from Bubble)
Product Name

Orders
Unique ID (PK default from Bubble)
Customer Name
List of carts

Cart
Unique ID (default from Bubble)
Product
Qty

The steps to create a new order is as follow:

  1. Fill in the customer information
  2. Add things to the cart.

In step 1, after next is clicked, I passed the order-id to step 2


Then, in step 2,
when i click + for the first time, it creates a new cart with the order id and qty = 1

then, when I click + for the second time, instead of adding the qty to become a total of 2, it shows up as a total of 3 in the UI


Although, in the dataset, it is showing correctly as 2

Any insights to fix are greatly appreciated.

Thank you,

1 Like