How to create relational custom states

I’m creating a marketplace for car rental companies and after choosing a car, the user can select optional add-ons. These add-ons are a table related to rental companies. Each add-on has a rental company, a type (Optionset), and a value.

Each rental company has different add-ons. I’m displaying them correctly in the repeating group. The problem is that it is possible to select more than one item per add-on, for example: Two baby chairs. And then, I don’t know how to store this in custom states.

It seems that I would need two related custom states, one representing the add-on and the other the quantity.

Here is the repeating group where the rental company’s add-ons are listed, and the user can select the quantities they want of each.

So, how can I store the add-on and the selected quantity without having to save to the database, with only custom states. Anybody can help-me, please?

Make the custom state a list

Yes, but I need to store information in the following format: ‘Add-on: Quantity’. However, in the custom state, I cannot store data with more than one field. Therefore, I think I need to have two custom states: one for the add-on name and another for the quantity. But, I need to find a way to create a relationship between them.

Please share a screenshot of the involved dataTypes and their fields

Down here you can see the data type “Opcional” (Add-on in English). Each “Locadora” (Rental in English) has a list of “Opcional”.

In this dynamic page, that represents a car from a rental, I have a repeating group which is supossed to list rental’s full list of add-ons.

As you can see, the user is able to select up to 2 items of each add-on. After that I need a way to store the add-ons he selected and the quantity.

Here’s the link to my Bubble editor: Tricer v2 | Bubble Editor

I see. Thank you!

A bit elaborate logic is required to build the functionality that I think you may be looking to achieve.

In general terms you need to:

  • Add the optionai to a list of optionais somewhere
  • Record the ordered quantity of each
  • With the above information you can add that payload to an order … I believe … I did not look into everything in detail

Look into content that explains how to create elaborate shopping cart functionality. Perhaps one of the below videos may cover some of the concepts needed by your app:

Hope the above helps! :slight_smile:

2 Likes

Thanks, bro! If I remember correctly, in the videos you sent me, they store the data in the database, but I wanted to do it using custom states. However, I figured out a way to do it with this video: https://www.youtube.com/watch?v=eAg_DvKmOA4&t=852s&ab_channel=Tout-en-un

This topic was automatically closed after 69 days. New replies are no longer allowed.