BEE Script: if ...
elseif (condition) statement;
[else statement;]
or if ...
elseif (condition)] { statement; ... }
[else { statement; ... }]
BEE Tag: <beeif ...>
...
<beeelseif "condition">
tag
...
[<beeelse>
tag
...]
</beeif>
Note: The condition is surrounded by a small bracket and therefore is taken literally. While you can (and sometimes need to) quote individual values in the condition, please do not quota the whole condition with double or single quote. Otherwise, the whole condition will be taken as a string (and will most likely to be evaluated to true unless it is blank or 0).
The "elseif" command starts a conditional block structure and therefore an "else" or a sequence of another "elseif" tag can follow the conditional block.
The condition will be evaluated for any BEE Variables before the truth value is determined. Please note that variables are evaluated as macros and therefore one should bear in mind the logical expression syntax. In particular, you need to quote strings as required. Please see the "if" command for examples.
The "elseif" construct is equivalent to "else" followed by "if". The only difference is that you do not need to have multiple curly brackets and excessive indentation for clarity.
Example 1: Using "else" then "if"
if ({form:Qty} > 100) {
var deliveryCharge = 0.0;
display 'Free delivery.';
} else {
if ({form:Qty} > 50) {
var deliveryCharge = 8.0;
display 'Delivery charge discounted.';
} else {
if ({form:Qty} >= 3) {
var deliveryCharge = 10.0;
display 'Thank you.';
} else {
var abort = 1;
display 'Minimum quantity is 3.';
}
}
}
Example 2: Using "elseif"
if ({form:Qty} > 100) {
var deliveryCharge = 0.0;
display 'Free delivery.';
} elseif ({form:Qty} > 50) {
var deliveryCharge = 8.0;
display 'Delivery charge discounted.';
} elseif ({form:Qty} >= 3) {
var deliveryCharge = 10.0;
display 'Thank you.';
} else {
var abort = 1;
display 'Minimum quantity is 3.';
}
If the condition is blank, it will evaluate to false.
After the "elseif" command is executed, the following BEE Variables are made available:
result%elseif:istrue |
Set to 1 if the condition evaluates to true, or 0 otherwise |
result%elseif:condition |
Set to the condition after variable evaluation |
|