Forum Academy Marketplace Showcase Pricing Features

Checkout system | custom states | list

Hi there!

I’m facing a problem. In the app is a cart where the user can add some products.

I created to custom states:

  1. a text list - for items
  2. a number list - for quantity.
    There are two inputs: one for item’s name; and other for quantity of each item.
    I made a workflow that set the custom state as: current custom state:plus item: input.
    There are two repeating groups (one of type text and another of type number). Datasource are the custom states.

But, when making this for the quantity; if the user puts Item A x 2, Then, if he tries to put item B x 2; it fails.
Because the repeating group items is showing both elements; but the repeating group number is showing only one “2”.

Why is it happening?

here you can see a video of what’s happening

Few suggestions:

  1. don’t user custom state here at all, have a cart table in the database with fields (user, item, quantity) - beyond the UI looking a little bit better (one table and not two), you won’t need to deal with two lists and the cart will persist if the user leaved an comes back on another day

  2. if you really want to keep the cart in the UI only, leave your two lists, but have only one table (let say on your item list), put two text object in the cell - one is current cell item, and the other is Number list item # Current Cell index…

You need to make another datatype called “Cart item” with a field for the text and a field for the quantity. When you add to cart you make a new Cart item. It’s because a 2 already exists in the list so it’s not adding another one.

1 Like

Hi there, @francochapa01… what is happening is quite simple… Bubble doesn’t allow duplicate values in lists. So, as Eldad and Tyler have suggested, you can use a custom data type, but if you really want to use a custom state, you can try this workaround for getting duplicate values into the list. In a nutshell, the workaround stores the numbers in a custom state with a state type of text, and you append a character after each number so you can split by that character when you want to break the text string in the custom state into the individual numbers.

Hope this helps.


Hi @eldad1 @tylerboodman and @mikeloc I really appreciate your comments.

I think I will go with the data type solution.

1 Like