Combine template variables with IF conditions, mathematical operators and text functions to show text only when a condition is met, calculate amounts, convert currencies and reformat booking data. You can use them wherever template variables are allowed, for example in Auto Actions, confirmation messages and invoices.
Table of Contents
- IF variables (smart logic)
- IF examples
- Mathematical operators
- Rounding and decimal places
- Currency conversion
- Text functions
- Write numbers in words
IF variables (smart logic)
An IF variable compares two values. It shows one text if the comparison is true and another text if it's false.
- Put a colon (
:) between the two values and before the first text. - Put a pipe (
|) between the two texts. - A text can be empty if you don't want to show anything for that result.
| Variable | Shows the first text if |
|---|---|
[IF=:if this:equals this:display this text|otherwise display this text] |
The values are equal |
[IFIN:if this:is contained in this:display this text|otherwise display this text] |
The first value is contained in the second |
[IFLIKE:if this:is like this:display this text|otherwise display this text] |
The values are equal, ignoring upper and lower case and spaces at the start and end |
[IF>:if this:is greater than this:display this text|otherwise display this text] |
The first value is greater |
[IF>=:if this:is greater than or equal to this:display this text|otherwise display this text] |
The first value is greater or equal |
[IF<:if this:is less than this:display this text|otherwise display this text] |
The first value is less |
[IF<=:if this:is less than or equal to this:display this text|otherwise display this text] |
The first value is less or equal |
[IFBETWEEN:if this:is between this:and this:display this text|if it is lower display this text|if it is higher display this text] |
The value is between the two limits. IFBETWEEN has a second and third text for values that are lower or higher. |
Nest IF variables
You can put IF variables inside other IF variables to build more complex logic. The inner IF must be processed before the outer IF.
- Each IF type also has a special version with
^and~as separators instead of:and|, for example[IF=^this^this^same~different]. - The special versions are processed first, so use them as the inner IF. The outer IF then works with their result.
- Use the special versions also when your data can contain
:or|characters. - Only one IF of each type can be used to build complex logic.
IF variables are processed in this order: all [IF=^ first, then all [IFIN^, and so on.
[IF=^[IFIN^[IFLIKE^[IF>^[IF>=^[IF<^[IF<=^[IFBETWEEN^[IF=:[IFIN:[IFLIKE:[IF>:[IF>=:[IF<:[IF<=:[IFBETWEEN:
IF examples
You can use other template variables inside IF variables, as in these examples.
| Variable | Result |
|---|---|
[IF=:[GUESTNAME]:Miller:yes|no] |
Shows yes if the guest's last name is Miller, otherwise no. |
[IF>:[NUMADULT]:2:please contact us about your bedding requirements|] |
Shows the text if there are more than 2 adults. Shows nothing for 2 adults or fewer. |
[IF<:[NUMADULT]:3:|linen for two adults is included free of charge] |
Shows nothing for fewer than 3 adults. Shows the text for 3 adults or more. |
[IF<=:[NUMADULT]:2:yes|no] |
Shows yes for 2 adults or fewer, otherwise no. |
[IF>=:[NUMADULT]:2:yes|no] |
Shows yes for 2 adults or more, otherwise no. |
[IFBETWEEN:[NUMADULT]:1:3:yes|too low|too high] |
Shows yes for 1 to 3 adults, too low below that and too high above it. |
[IFLIKE:[GUESTTITLE]:Mr:Dear|Hi] |
Shows Dear if the guest title is Mr, in any upper or lower case, otherwise Hi. |
[IFIN:John:[GUESTFIRSTNAME]:Hi John|Your name does not contain John?] |
Shows the first text if the first name contains John, otherwise the second text. |
[IFIN:CHECKIN:[BOOKINGINFOITEMS]:[BOOKINGINFOCODETEXT:CHECKIN]|] |
Shows the value (date and time) of the Booking Info Code CHECKIN if it has been added to the booking, otherwise nothing. |
[IFIN:DEPOSIT:[BOOKINGINFOCODES]:|[IF=:[GUESTCOUNTRY2]:AU:Credit card details are required |A deposit is required]|No deposit is required] |
For bookings with the Booking Info Code DEPOSIT, shows Australian guests "Credit card details are required" and other guests "A deposit is required". Bookings without the code show "No deposit is required". |
[IF<:[INADVANCE]:|[IFIN:TRANSFER:[BOOKINGINFOCODES]:3:Payment Due Date: ASAP |Payment Due Date: [FIRSTNIGHT:- 30days]]|] |
Shows a payment due message to guests with the Booking Info Code TRANSFER, 3 days before check-in. |
[IF=:[STATUS]:Confirmed:PAID|[IF<^[INADVANCE]^30^Payment Due Date: As soon as possible~Payment Due Date: [FIRSTNIGHT:- 30 days]]] |
Shows PAID for Confirmed bookings. For other bookings, shows "Payment Due Date: As soon as possible" if check-in is less than 30 days away, otherwise a due date 30 days before check-in. |
[IFBETWEEN:[TURNOVERDAYS]:0:3:yes|no] |
Tests whether the next arrival in the same unit is 0 to 3 days away. Use it, for example, to offer a late check-out or extra nights when there's a gap between bookings. |
[IF>:[VACANTDAYS]:1:yes|no] |
Tests the number of vacant days between the previous check-out and this check-in. Use it, for example, to offer an early check-in or extra nights. |
[IF=:[LEAVINGDAY:{%a}]:Sun:|[IF>=^[TURNOVERDAYS]^1^yes~no]] |
Tests whether check-out is on a Sunday and there's a gap of 1 or more days before the next booking. |
[IF=:[LEAVINGDAY:{%u}]:1:yes|[IF=^[LEAVINGDAY:{%u}]^3^yes]] |
Tests whether check-out is on a Monday or a Wednesday, for example to remind guests that it's bin collection day. |
[IF=:[LEAVINGDAY:{%u}]:1:yes|[IF=^[LEAVINGDAY:{%u}]^3^yes][IF=^[LEAVINGDAY:{%u}]^6^yes]] |
Tests whether check-out is on a Monday, Wednesday or Saturday, for example to message the cleaning team for that day. |
[IF<^[AUTHORIZEUNTIL{%Y-%m-%d}]^[CURRENTDATEYYYY-MM-DD]^yes~no] |
Tests whether the Stripe card authorisation has expired, so you can authorise the card again with an Auto Action. You need several Auto Actions, based on your minimum and maximum stay. |
For day-of-week codes such as %a and %u, see Template Variables: Date and time format codes.
Mathematical operators
Place mathematical operators between two numbers or between two template variables that return a number.
| Operator | Example |
|---|---|
[+] |
2 [+] 3 = 5 |
[-] |
5 [-] 1 = 4 |
[*] |
3 [*] 4 = 12 |
[/] |
15 [/] 5 = 3 |
[MIN] |
2 [MIN] 3 = 2 |
[MAX] |
2 [MAX] 3 = 3 |
Brackets don't control the order of calculation. The order is always *, /, +, -, MIN, MAX. Because * is calculated first, to take 20% of a result that includes a subtraction, multiply each value separately:
[INVOICECHARGESNUM][*]0.2[-][INVOICESECONDITEMNUM][*]0.2[-][COMMISSIONNUM][*]0.2
Tip: use Property Templates 1–8 and Room Templates 1–8 for calculations. For example, to show 10, set Room Template 6 to
[ROOMTEMPLATE7][+][ROOMTEMPLATE8], and enter 4 in Room Template 7 and 6 in Room Template 8. When you calculate with Room Templates, use Room Template 8 before Room Template 7. A Property Template can use a calculation from a Room Template, but not the other way around: Property Template 1 can show[ROOMTEMPLATE6]with the result 10.
Note: always use the template variables ending in NUM. Calculations only work with numbers that have a decimal point (not a decimal comma), no thousands separator and no currency symbol.
Rounding and decimal places
Add a dot and the number of decimal places to the operator. This works on all operators, including [MIN] and [MAX].
| Rounding | Example |
|---|---|
| Default (no rounding) |
2 [/] 3 = 0.66666666666667 |
| Nearest whole number |
2 [/.0] 3 = 1 |
| 1 decimal place |
2 [/.1] 3 = 0.7 |
| 2 decimal places |
2 [/.2] 3 = 0.67 |
| 3 decimal places |
2 [/.3] 3 = 0.667 |
| 4 decimal places |
2 [/.4] 3 = 0.6667 |
Currency conversion
[CONVERT:EUR-USD] returns the current conversion rate between two currencies. Use it with mathematical operators to show amounts in another currency. All currencies of the booking page currency selector are supported.
For example, [INVOICECHARGESNUM] [*.2] [CONVERT:EUR-USD] converts the invoice charges from euros to US dollars with two decimal places.
You can also use it in a channel's multiplier setting, for example with hotel ID 123456:
| Multiplier | Result |
|---|---|
123456*[CONVERT:USD-EUR]* |
Converts USD to EUR at today's rate. The * at the end converts the value back to USD when the booking is imported. |
123456*[CONVERT:EUR-USD] |
Converts EUR to USD. |
123456*[CONVERT:USD-EUR][/]0.85 |
Converts to EUR and divides the price by 0.85, which raises it by about 15%. |
Text functions
| Variable | Result |
|---|---|
[REPLACE|searchForThisText|replaceWithThisText|textToSearch] |
Replaces searchForThisText with replaceWithThisText in textToSearch. |
[SUBSTR|startCharacterNumber|numberOfCharacters|textToGetSubstringFrom] |
Returns part of textToGetSubstringFrom, starting at character startCharacterNumber (0 is the first character) with a length of numberOfCharacters. For example, [SUBSTR|0|4|[GUESTPHONENUM]] returns the first 4 characters of the guest's phone number. |
[TRIM| string to trim ] |
Removes spaces from the start and end of the text. |
Write numbers in words
[INWORDS] writes out a number in words. This works in English only.
| Variable | Result |
|---|---|
[INWORDS] 10 |
ten |
[INWORDS] [INVOICEPAYMENTSNUM] |
The sum of all payments on the invoice, in words |
[INWORDS] [INVOICEPAYMENTSNUM] [+] 10 |
The sum of all payments plus 10, in words |