Custom State - Adding more of the same thing to a list

I have a order form where i want to add a “product” to a state before saving it to database. Manage to add it however how to i solve the problem of not being able to add same object into the list?

Or any idea how to optimize this better?

Order form :

Add only 1 object but cant add more same object

how the add button workflow works :

Thanks!

Hi @mstrmorgana,

I couldn’t find a way doing this with states.

Anyways this could be easily implemented otherwise with changes to your database.

  1. (Optional but nice i think for usability) Simply put a “– Quantity +” interface into the repeating group where the user can choose the quantity.

  1. Create a new data type called “Order item/object” with Quantity default being 1

  2. Everytime your add button is clicked create a new order item with the selected product unless the user has already selected it.

  3. If it has already been selected tick the quantity up by 1.

  4. Finally, add the order item to your state of the repeating group. (which you would’ve to change to a list of order items/objects)

Hope this helps.

Best,
Julius

Hi,

Initially i wanted to work with thing but having an issue with other info i wanted to include once object has been finalize, as u can see in my first picture. Thus i wanted to use state as a method of not creating anything in database before finalizing order.

But, let me look into this and see if it helps.

Million of thanks!

I wonder if it’s related to this bug which has been reported and confirmed. I have not yet heard back about the status of a fix.

I see, it could be a bug related to state and not thing.

Just heard from Bubble that this has been fixed, and I have confirmed that’s the case. :slightly_smiling_face:

(…which means that if your issue still occurs, it was unrelated to that bug.)

I have tried mine, still doesnt work. so its not related to bug. owh well…

@TipLister

I have tried your ways but its more convoluted than i thought.

Reason being - Order and Product is 2 different “thing”. The order might store multiple product.

Reason i choose state is because of building an ID to tie with each Order.

1 order might contain 1 ID - multiple product selection and a sum of total price (with customer details). Thus my logic is, you shouldnt create a thing first but rather view it before initiating creation of Order.

The other option is potentially like your concept of quantity is whenever the button of add is initiated - keep adding the selected item (something i failed to execute as well).

Probably i need an idea more than a solution at this point.

Would appreciate any kind of idea for now.

I manage to crack the state problem with the idea of quantity.

What i did is 1st create another state for default value for quantity as 0.

Next for the workflow is for "+: icon - set state to add 1 for everytime it gets clicked, same logic for “-” icon except minus 1

For control, everytime each RG selected = 0, you need to remove the item from listing.

Now, the interesting question next is…

how do i fetch the total of the state of current price to a text of input field? because its a state, its not showing up as an element to sum it.

Any good idea?

Currently mental block. Any suggestion (including to remodel the whole steps) is appreciated.

Hello @mstrmorgana

Ever solve this?

I believe this might work: The value becomes “the content of the custom state” converted to list - plus item - your selection image|340x376

@TipLister
I have almost the same requirement.
Onclick of add button i want element to be added to custom state which is of a API type.


So i was trying to create json and send that object to Custom state. But as json putput is on text format i’m not able to assign it. Do you any idea about how to implement this ?

this stuff is difficult in bubble,

i solve it by creating a new thing for every row whenever plus is clicked and then increasing the quantity in that and summing them.

i believe you can also use listshifter plugin

@TipLister
Thank you for quick reply. I want the way where we don’t need to create record in bubble’s database.
without creating record can we achieve it? And what is the requirement of listshifter plugin over here?