Conditions and expressions

PROFESSIONAL

In nShift Checkout you can use conditions and expressions to adapt your checkout to your needs.

Conditions and expressions are written using parameters, functions and operators.

Conditions

Conditions are used to determine what should be shown in your checkout.

  • Conditions can be used in condition fields for e.g.:

    • Delivery options

    • Services

    • Addons

    • Price

  • Conditions can include parameters.

  • Conditions can include predefined functions.

  • Conditions are written using operators.

Expressions

PREMIUM

Expressions are used to dynamically modify certain text fields.

  • Expressions can be used in text fields such as:

    • Fields for titles

    • Captions for field X

    • Price

    NC_Expressions1.png
  • Expressions can include predefined functions.

  • Expressions can include parameters.

  • Expressions can be written using operators.

  • Expressions must be written inside curly braces, “{}”.

    Curly braces are not allowed inside strings in these fields.

Some parameters already exist in the system, but you can also add your own.

Parameters are configured in the GUI. If you do not set a default value, the parameter must be set in the API call. Parameters connected to the sender are set automatically.

Set default value for a parameter

  1. Go to Maintenance > Delivery checkout.

  2. When creating a new delivery checkout you add default values to parameters on the New delivery checkout page.

    To add default values to parameters on an existing delivery checkout, click UO_Edit_icon_old.gif to the left of the delivery checkout on the Delivery checkout page.

  3. Click UO_Edit_icon_old.gif to the left of a parameter.

  4. The parameter appears in the field Name under the parameter list.

  5. Enter a value in the Default field using the Type defined for the parameter.

  6. Click Save.

Create and add your own parameters

You can add parameters to a new or existing delivery checkout.

  1. Go to Maintenance > Delivery checkout.

  2. When creating a new delivery checkout you create new parameters on the New delivery checkout page.

    To add new parameters on an existing delivery checkout, click UO_Edit_icon_old.gif to the left of the delivery checkout on the Delivery checkout page.

  3. In the Parameters section you can enter name, type and default value.

  4. Click New parameter.

You delete the parameter by clicking UO_Delete_icon_old.gif next to it.

Both conditions and expressions can use functions. A function is an advanced way to access dynamic data, such as next holiday in the receiver's timezone or tomorrow being a working day in the sender's timezone.

Some functions allow arguments, i.e. input which will alter the way the function behaves. If no argument is supplied, all functions will behave in a standard way. For example, functions which allow a date as argument will use today's (depending on timezone) date if no argument is supplied. If a date is supplied the result be based on that date.

Note

A function without a parenthesis equals a function with an empty parenthesis, i.e. both will result in a default function behavior.

The following functions are available:

Function

Result type

Argument type

Description

todayIsWeekendSender()

boolean

N/A

Today is weekend in sender's timezone.

todayIsWeekendReceiver()

boolean

N/A

Today is weekend in receiver's timezone.

todayIsHolidaySender()

boolean

N/A

Today is holiday in sender's timezone.

todayIsHolidayReceiver()

boolean

N/A

Today is holiday in receiver's timezone.

dateNowSender()

date

N/A

Current date in sender's timezone.

dateNowReceiver()

date

N/A

Current date in receiver's timezone.

dateTimeNowSender()

dateTime

N/A

Current date and time in sender's timezone.

dateTimeNowReceiver()

dateTime

N/A

Current date and time in receiver's timezone.

todayAsNumberInYearSender()

integer

N/A

Today is day number X in a year in sender's timezone.

todayAsNumberInYearReceiver()

integer

N/A

Today is day number X in a year in receiver's timezone.

weekdayNumberSender()

integer

N/A

Current weekday number in sender's timezone.

weekdayNumberReceiver()

integer

N/A

Current weekday number in receiver's timezone.

monthNowSender()

string

N/A

Current month in sender's timezone.

monthNowReceiver()

string

N/A

Current month in receiver's timezone.

dayNowSender()

string

N/A

Current day in sender's timezone.

dayNowReceiver()

string

N/A

Current day in receiver's timezone.

timeNowSender()

time

N/A

Current time in sender's timezone.

timeNowReceiver()

time

N/A

Current time in receiver's timezone.

nextHolidayDateSender()

date

date

Next holiday date in sender's timezone.

nextHolidayDateReceiver()

date

date

Next holiday date in receiver's timezone.

nextWorkDateSender()

date

date

Next working date in sender's timezone.

nextWorkDateReceiver()

date

date

Next working date in receiver's timezone.

nextWorkDaySender()

string

date

Next working day in sender's timezone.

nextWorkDayReceiver()

string

date

Next working day in receiver's timezone.

The following operators are used to state conditions.

Operator

Meaning

>

greater than

>=

greater than or equal to

<

less than

<=

less than or equal to

=

equal to

!=

not equal to

!

not

&

and

|

or

?

list <parameter> ? "<list name>"

Tip

  • When using only &-operators in an expression, all expressions must be true for the entire expression to be true.

    Example:

    tocountry = "SE" & fromcountry = "SE"

  • When using only |-operators in an expression at least one of the expressions must be true for the entire expression to be true.

    Example:

    tocountry = "SE" | tocountry = "DK" | tocountry = "FI"

  • Always use excluding conditions in e.g. a price list. Otherwise it's the order that decides.

    Example:

    cartprice >= 500.0

    cartprice < 500.0

  • Use parentheses to decide in which order expressions should be evaluated to render the expected result.

    Example:

    weight <=20.0 & tocountry = "SE" | tocountry = "DK"

    results in

    weight = 40.0 and tocountry=DK is true

    weight = 10.0 and tocountry=DK is true

    while

    weight <=20.0 & (tocountry = "SE" | tocountry = "DK")

    results in

    weight = 40.0 and tocountry=DK is false

    weight = 10.0 and tocountry=DK is true

  • Instead of creating new parameters or having to write long and complicated expressions you can use ! and != to invert boolean expressions.

    Example:

    !B2B is true if B2B is false

    tocountry != "SE" is true if tocountry is not SE

  • Use condition listscondition lists to evaluate against a large amount of values, e.g. zip codes.

    Example:

    tozipcode ? "zipcodes_in_gbg_sthlm"

Condition lists make it easy to import large amounts of data.

Create a list in .txt format with, for example, zip code ranges and/or single zip code items. The ranges and items must be entered on separate rows. Use a semicolon (;) between items to indicate a range.

Example

11130;11140

11145

11160;11170

11175

11180;11190

41130;41140

41145

41160;41170

41175

41180;41190

Upload and activate a condition list

You need to upload and activate the condition list.

Tip

To always activate the condition list immediately when uploading, use the uselatestlistparameter.

  1. Go to Maintenance > Delivery checkout.

  2. Click Condition lists.

  3. Click Import and select the condition list file.

  4. Search for the list to activate it manually. The list has status "OK".

  5. Click UO_Show_icon.gif to the left of the list and then Activate. An active list has status "OK (Active)".

You can change the name of the list or delete it, but you can not deactivate it.