I'm using this Drupal module that's called Webform Calculator, and it makes us of so-called operators.
There's one formula based on operators that almost does the job:
({total_weight}==0? 0:0) || ({total_weight}<=2? 5:0) || ({total_weight}<=10? 6:0) || ({total_weight}<=30? 10.5:0)
This is what it's doing right:
The only that it doesn't work out (which is actually the first part of the formula):
It keeps throwing 5 at me. Anyone has an idea what I'm getting wrong, and what this is called in the first place (having a hard time finding references on Google)?
({total_weight}==0? 0:0) || ({total_weight}<=2? 5:0) || ({total_weight}<=10? 6:0) || ({total_weight}<=30? 10.5:0)
If total_weight is 0 then it can be interpreted as:
(0 || ({total_weight}<=2? 5:0) || ({total_weight}<=10? 6:0) || ({total_weight}<=30? 10.5:0)
or
(false || ({total_weight}<=2? 5:0) || ({total_weight}<=10? 6:0) || ({total_weight}<=30? 10.5:0)
Which causes the 2nd condition to execute. 0<=2
so the ternary "returns" 5