Conditionals - "hierarchy"/order of

I need to create a kind of hierarchy for my conditionals so that I can quote the correct price to a user.
So, if the Current User is subscribed (ie, their Subscribed field is set to ‘Yes’) they pay the product’s wholesale price.
Otherwise…
If the Current User is a Founder User (ie, their UserType field is set to ‘Founder’ they pay the selected product’s wholesale price + nn%
If the Current User is a Standard User (ie their UserType field is set to ‘Standard’ they pay the selected product’s wholesale price + nnn%
I’m using an Expression to calculate the price as below;

The thing is, there’s a 4th criteria as per this screenshot below that looks at a Custom State where I store the selected Venue’s Type so that if the selected Venue’s Venue Type is “High Volume”, the Price should be only be n%

Screen Shot 2022-03-07 at 13.34.32

However, even though this is the fourth Condition in the list, it’s overriding all the others (weirdly even when the condition’s turned off) and it seems that Bubble is reading all the conditions in order and applying the last one it read that was true whereas I thought it read conditions until it found one that was true. This means that my conditions aren’t working.

Can anyone point me in the right direction with this?

Hi there, @joefarrowsmith… about this…

Yup, that’s how it works.

And about this…

The on/off switch doesn’t actually do what a lot of folks think it does, meaning that it doesn’t stop conditions that are off from being evaluated. That switch is only used for display purposes so you can see what a condition will do when it is true.

Hope this helps.

Best…
Mike

Ahhh, the plot thins…thank you!

So, is there a way to get it stop applying conditions when it finds a true one? Kind of like an IF statement in Excel I guess.

it seems that Bubble is reading all the conditions in order and applying the last one it read that was true whereas I thought it read conditions until it found one that was true. This means that my conditions aren’t working.

No, Bubble will read them through in order, so if the last one is true, that will always be the one that’s applied.

And, as @mikeloc pointed out, you can’t turn conditions on or off in the property editor - the on/off toggle is just so you can see them being applied (or not) in the editor.

So to get things working the way you need them to, it might be possible just to reorder the conditionals (but that entirely depends on the possible combinations of conditions within your app),

OR you’ll need to apply the opposite login to each other condition to stop any confusion about which one you want to be applied - e.g. when the User’s Subscribed is Yes AND the User’s User Type is NOT Founder AND when Input VenueType value IS NOT High Volume etc.

In other words you need to exclude all of the other possibilities in each condition, so that only one will ever be true (otherwise the last one that’s true will be applied).

2 Likes

What Adam said… it’s all about the structure and order of the conditions because Bubble is going to evaluate them all from top to bottom and apply the last one that is true.

1 Like

Nice one. That makes sense. I think I can change the order but will also throw in a few booleans to keep them on track. Knowing the order is very helpful so thank you both. My lazy logic is the culprit here.
Have a good day and thanks again

2 Likes

Thank you ever so much for taking the time out to explain this. The addition of the boolean bits makes it helpful.
Have a lovely day - your input has improved mine!

1 Like