Update quantity in shopping cart

Hi everyone,

I’m starting with Bubble, and i’m trying to build a basic marketplace, i have built the shopping cart linked to a user, the user can view a product and add it to his cart but i really don’t know how to manage the quantity update in the shopping cart, as you can see when i add the same product to my cart, i have twice the same product instead of having it one time with the updated quantity.

I tried to add a condition in the workflow “create new thing” in the shopping cart " only when the product (current page product) in not in the user’s cart" , but i can’t manage to do it properly,

can somebody help me on that?




Capture d'écran 2024-03-31 123431
Capture d'écran 2024-03-31 cartItem

Check this sample app I made a while ago for a video game inventory, I feel like its almost the exact same thing as a shopping cart.

Preview: Bubble | No-code apps
Editor: game-inventory | Bubble Editor

Datatypes:
Game Item = Product
Inventory = Cart
Inventory Item - Cart Item

1 Like

yes that’s what i was looking for, thank you! i’ll try to implement it on my site

1 Like

I agree with Tyler. You’re right that a list will only contain unique items, so what your “Cart” data type needs to contain is a list of “Line Items” (or whatever you want to call it), or if you wanted to avoid lists altogether then you could make it so that each “Line Item” has a field for “Cart” to which it belongs.

A “Line Item” could consist of an “Item”, unit price, quantity, subtotal, and so on.

2 Likes

on add to cart you need a check
active cart for current user does not have current product (only then create a new line)

If the product exists just update the quantity and it should work perfectly

1 Like

i applied what you said regarding the addition of a “new cart line” when an item is added to the cart and it worked perfectly, thank you very much, i just created the cart right after the user signs up!


2

4