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:
- a text list - for items
- 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?
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.
Best…
Mike
1 Like
Hi @eldad1 @tylerboodman and @mikeloc I really appreciate your comments.
I think I will go with the data type solution.
Thanks!
1 Like