Expressions can be used in within the template to allow for variable information to be displayed either by using a single variable or based on a condition. This allows templates to be more dynamic, where a single piece of information changes, without having to create a new template.
Since the design of a template is based on variable information these are used to produce data where you know what the data, or in other words "Variables are symbolic names given to a an unknown piece of information". The available variables can be found in drop down boxes for the element being edited, once selected they will produce the variable in the editing panel. An example of a variable would be [{Source}]. These are always surrounded by two types of brackes [] on the outer and {} on the inner. This allows linnworks to determine that it is a variable.
These variables can be used in many statements, conditions or even just to product some information.
Example - Using variables to produce information
It's possible to put a variable in the middle of a sentence to produce information about for example an order.
The above will auto fill the [{Source}] variable with the location of the order. So if the order was from Amazon it would produce.
AND |
The AND operator can be used when using multiple variables within a condition. When using the AND operator all conditions have to be true for the output to display. [{Source}]="EBAY" AND [{SubSource}]="EBAY0" It is not possible to use an AND for multiples of the same variable, i.e. an order cannot have source AMAZON and EBAY. |
OR |
The OR operator can be used when using multiple variables within a condition. When using the OR operator only one of the conditions has to be true for the output to display. [{Source}]="EBAY" OR [{Source}]="AMAZON" |
= |
The equals sign is used to evaluate the variable against the given text. The text provided must match the variable exactly for the condition to be true |
<> |
This operator means NOT EQUAL or in other words does not equal. [{Source}]<>"EBAY" The above condition will be true when the source of an order is not ebay. |
> |
This operator means GREATER THAN. This can be used when evaluating numerical values. [{fTax}]>10 This will mean that anything with tax above 10 will be true. If tax is 10.00 then the condition is false as it is greater than, not greatern than or equal to. |
< |
This operator means LESS THAN. This can be used when evaluating numerical values. [{fTax}]<10
This will mean that anything with tax below 10 will be true. If tax is 10.00 then the condition is false as it is less than, not less than or equal to. |
>= |
This operator means GREATER THAN or EQUAL TO. This can be used when evaluating numerical values. [{fTax}]>=10This will mean that anything with tax above or equal to 10.00 will be true. |
<= |
This operator means LESS THAN or EQUAL TO. This can be used when evaluating numerical values. [{fTax}]>=10This will mean that anything with tax below or equal to 10.00 will be true. |
There are three types of formulae that can be used in Linnworks expressions iif, round and eval. It is possible to calculate within formulae using simple maths (Add, Subtract, Multiply and Divide), it's also possible to separate calculates using rounded brackets.
An IIF or IF statement is a conditional statement that revolves around a statement being true or false. If the condition in the statement is true then it will return the first, else it will return the second value.
EVAL{BEGIN}IIF[1=1,"One Equals One","One Does Not Equal One"]{END}
In words: Evaluate -> IF 1 EQUALS 1 > Return "One Equals One" > Else Return "One Does Not Equal One"
EVAL{BEGIN}IIF[[{Source}]="AMAZON","You are an Amazon Customer","You are not an Amazon Customer"]{END}
If the order has come from Amazon it will return "You are an Amazon Customer" otherwise it will return the second statement
AND conditions can be used when evaluating two different variables.
EVAL{BEGIN}IIF[[{Source}]="AMAZON" AND [{SubSource}]="Your Amazon Store","Hello","You are not an Amazon Customer"]{END}
In words: IF Order Source is AMAZON and the Sub Source is Your Amazon Store > Return "Hello" ELSE Return "You are not an Amazon Customer"
AND conditions can be used when evaluating two different variables
OR can be used when evaluating the save variable twice.
EVAL{BEGIN}IIF[[{Source}]="AMAZON" OR [{Source}]="EBAY","True","False"]{END}
The above condition will return True when the source is Amazon or Ebay
If you want to group conditions so that a group must be true before the next statement this can be done by bracketing the sets of conditions.
EVAL{BEGIN}IIF[([{Source}]="AMAZON" OR [{Source}]="EBAY") AND ([{cCountry}]="United Kingdom" OR [{cCountry}]="IRELAND"),"True","False"]{END}
The above condition will only return true if the source is (AMAZON or EBAY) AND Country is (United Kingdom OR Ireland)
It is possible to return variables based on a condition, this can be done by simply adding the variable to the return value.
EVAL{BEGIN}IIF[[{Source}]="AMAZON" OR [{Source}]="EBAY",[{Source}],""]{END}
For the above example IF the source is AMAZON or EBAY the variable will return the Source name, either AMAZON or EBAY. Otherwise it will return nothing.
A second IIF can be used to to evaluate the same variable more than once
EVAL{BEGIN}IIF[[{fTotalCharge}]>34.99 AND [{fTotalCharge}]<=79.99 ,"*** RECORDED ***",""]{END}EVAL{BEGIN}IIF[[{fTotalCharge}]>79.99,"*** COURIER ***",""]{END}
In words: IF Order Total Charge is greater than 34.99 AND less than or equal to 79.99 output "*** RECORDED ***", then make another check IF Order Total Charge Source is greater than 79.99 output "*** COURIER ***"
The rounding feature is used to round numerical values to the nearest decimal place given the rounding decimal place specified.
EVAL{BEGIN}N2[10]{END}
Returns: 10.00 as it has been set to round to 2 decimal places (N2)
EVAL{BEGIN}N2[12.99*0.2]{END}
Returns: 2.60 given that 12.99*0.2 is 2.598 rounded up.
It is only possible to add, subtract, devide and multiply.
EVAL{BEGIN}N2[([{fTotalCharge}]-[{fPostageCost}])*0.2]{END}
In this example we are doing the Following (TotalCharge - PostageCost) * 0.2
EVAL or Evaluate is a method of returning TRUE or FALSE
EVAL{BEGIN}10+1=11{END}
This will return TRUE as 10+1 is 11, if it were not false would be returned
EVAL{BEGIN}([{fTotalCharge}]-[{fPostageCost}])>100{END}
The above calculation is determining if the total charge for the order, minus the postal cost is greater than 100, if it is TRUE will be returned, else false will be returned.