Logical operators

You can combine filter expressions by using conditionals. This allows you to build powerful filtering logic.

AND

AND is the conjunction operator.
The following filter returns items which meet two conditions: the brand is "abcd" and the price is 10 or more.

brand == "abcd" AND price >= 10

OR

OR is the alternative operator.
The following filter returns items which meet at least one of the conditions:

  • brand is "abcd"
  • the price is 10 or more
brand == "abcd" OR price >= 10

If both conditions are met, the filter also matches the items (and/or logic).

NOT

NOT is the negation operator.
The following filter returns items whose brand is not "abcd":

NOT(brand == "abcd")

IF

If you want to add conditional logic to the filter, you can use the IF statement.

IF(predicate, thenFilter, elseFilter)

where:

  • predicate is a logical expression in which you can use the context, but you cannot use properties of the item that is being tested against the filter.
  • thenFilter - is returned if the predicate is true.
  • elseFilter - is returned if the predicate is false.

Example:

A basic IF statement:

IF("New" IN context.tags, price > 100, price <= 100)

If the context profile’s tags include "New", the resulting filter is price > 100. Otherwise, it is price <= 100.

Example:

IF statement with the ALL/NONE function:

IF("New" IN context.tags, price > 100, ALL)

If the context profile’s tags include "New", the resulting filter is price > 100, otherwise the filter matches all items in the database.

Example:

IF statements nested in another IF statement:

IF("New" IN context.tags, price > 100, IF(context.brand == "abcd", price <= 100, ALL))
  • If the context profile’s tags include "New", the filter is price > 100, otherwise the nested IF statement is evaluated.
  • In the nested IF statement, if the context item’s brand is abcd the filter is price <= 100, otherwise the filter matches all items in the database.

Example:

IF statement with the AND logical operator in the predicate:

IF("New" IN context.tags AND context.brand == "abcd", price > 100, price <= 100)

If the context item has the tag New and its brand is abcd, the filter matches items whose price is more than 100.

Grouping expressions

The parentheses () allow you to group conditions in order to create more complex and nested expressions.

Example:

(brand == "abcd" AND price >= 10) OR brand == "efgh"

The filter returns items which meet at least one of the following conditions:

  • brand is "abcd" while the price is 10 or more (both conditions must be met).
  • brand is "efgh".
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker