Ok so I just set up five custom states and everything seems to be working. I would go through the app in preview mode (clicking on images to ‘select’ features of the pen) then come back to this.
Custom states are a little tricky to explain but the more you look at them in the workflow, the more they will make sense I didn’t understand them for the longest time. So, to make things simple, I assigned all of the custom states to the page “Which I just renamed: ‘customize_page’”. Every element can have an unlimited number of custom states, but you have to define which element, and the page is considered an element. So before doing anything, here is how you create a custom state. For example purposes let’s say nothing is visible on page load, but we want the Step 1 group to be visible when our custom state is “Step 1”. So in the workflow we’ll say "When page is loaded → Element Actions → Set State and be presented with this window:
Our element is the page itself (“customize_page”).
The custom state we’re creating is called “Current View” (Type: Text, List: No):
And then we manually enter the value (Step 1)
“Current View” is used to tell the page which ‘Step’ the user is on. Through the workflows, you will find a total of four values for that custom state “Step 1, Step 2, Step 3 (Ballpoint), and Step 3 (Fountain)”. So the state remains the same, but the values change depending upon what is clicked and what is currently shown on the page:
But custom states don’t do anything until there is conditional formatting set up on those groups themselves. This is where we connect custom states to the groups on the page. So now you would navigate back to the UI editor, and in the conditional formatting of each group you would tell Bubble:
And that’s how the ‘Current View’ works. Please let me know if any of that sounded confusing. Aside from Current View, the other Custom States created are:
Pen Style
Pen Type
Pen Wood
Total Price
These are different from Current View because they are not ‘texts’; their data types are custom. Meaning Pen Type’s Data Type is Pen Type (same as the Step 1 Repeating Group Data Type), Pen Wood’s Data Type is Pen Wood (same as the Step 2 Repeating Group Data Type) Pen Style’s Data Type is Pen Style (same as the Data Type for both Step 3 Groups). So for example, in Step 1 when the User clicks the image of the Ballpoint Pen, that sets the state of customize_page’s Pen Type to equal the selection the User just clicked on (Ballpoint pen). This process repeats for the Pen Wood and Pen Style.
We also calculate cost as we go here, so customize_page’s Total Price is equal to the sum of the cost of each selection the User has made thus far:
It begins at 0 (when nothing is selected)
and updates every time anything is clicked:
I know all of this can be pretty confusing at first glance, but if you go slowly through each workflow they really will start to make sense. It seems like a lot of workflows but that’s just because we have to be specific in telling Bubble exactly what to do when there are variations. Please let me know if any of this sounded confusing.
*I also just added another part to the workflows which occur when the ‘back button’ is clicked. If a User originally had a ballpoint pen and selected a Ballpoint Style, then they go back to change their minds to a fountain pen, then once back is clicked on 'Step 2 or ‘Step 3’ then it will clear the Pen Style originally selected on the first run through. So, a Ballpoint style isn’t kept when the User changes to a Fountain pen, or vice versa.