|
|
Template Designer ExpressionsOverviewExpressions 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. ExpressionsVariablesSince 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. Thank you for ordering from our [{Source}] store, please come back soon.
The above will auto fill the [{Source}] variable with the location of the order. So if the order was from Amazon it would produce. Thank you for ordering from our AMAZON store, please come back soon.
Operators
FormulaeThere 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. IIF StatementAn 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. Example - Returning TextEVAL{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" Exampe - Using variables in conditionsEVAL{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 Example - Using multiple conditions - ANDAND 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 Example - Using multiple conditions OROR 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 Example - Using multiple conditions (parentheses)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) Example - Returning VariablesIt 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. RoundingThe rounding feature is used to round numerical values to the nearest decimal place given the rounding decimal place specified. Example - Simple rounding of a numerical valueEVAL{BEGIN}N2[10]{END}
Returns: 10.00 as it has been set to round to 2 decimal places (N2) Example - Simple calculationsEVAL{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. Example - Rounding Variables and CalculationEVAL{BEGIN}N2[([{fTotalCharge}]-[{fPostageCost}])*0.2]{END}
In this example we are doing the Following (TotalCharge - PostageCost) * 0.2 EvaluateEVAL or Evaluate is a method of returning TRUE or FALSE Example - Simple calculationEVAL{BEGIN}10+1=11{END}
This will return TRUE as 10+1 is 11, if it were not false would be returned Example - Using VariablesEVAL{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. Knowledge Base topics |