Skip to main content

Evaluation order for rules and cart item filters

Campaigns, cart item filters and rules, as well as conditions and effects within rules, are evaluated in a specific order by the Rule Engine.

Campaigns are evaluated in the order you set in the Priority section of your Application. The order in which rules and cart item filters are evaluated depends on the order in which you create them and the types of effects in your rules.

Evaluating cart item filters

To increase performance, the Rule Engine evaluates cart item filters only in the following cases:

  • A condition referencing a cart item filter is about to be evaluated or a valid effect referencing a cart item filter is going to be applied.

    note

    Only if the effect type is not discount or update.

    In this case, only the cart item filter referenced by the condition or effect is evaluated.

  • A discount effect or an update effect is about to be evaluated.

    In this case, the Rule Engine evaluates from top to bottom all cart item filters that haven't yet been evaluated.

Evaluating rules

The campaign rules are evaluated by the Rule Engine from top to bottom as they appear in the Rule Builder section.

important

Before evaluating the campaign rules, the Rule Engine collects any customer profile data using the profile's integration ID, as that data may be required to evaluate the rules.

All conditions of a rule are evaluated and all its effects are applied before evaluating the next rule.

Evaluating conditions

The conditions of each rule are evaluated by the Rule Engine from top to bottom as they appear in the rule.

All the conditions of the same rule are evaluated before evaluating the effects.

Evaluating effects

The Rule Engine evaluates whether the effects of each rule can be applied. It does it based on the order in which the effects appear in the rule, from top to bottom.

Each valid effect is added to the array of effects of the customer session response as the Rule Engines evaluates if it can be applied, so the Rule Engine takes the effect into account when evaluating if the following effects can be applied.

note

Any existing campaign budgets are checked when evaluating if the effects that impact them can be applied.

Example

For this example, consider a campaign with 3 cart item filters and 2 rules. The first rule has 2 conditions and 1 effect, and the second rule has 1 condition and 2 effects.

Cart item filtersRule 1Rule 2

Filter 1

Filter 2

Filter 3

Condition 1

Condition 2

Effect 1

Condition 1

Effect 1

Effect 2

Also consider the following:

  • Filter 2 is referenced by Condition 2 in Rule 1.
  • Filter 3 is referenced by Effect 2 in Rule 2.
  • Effect 1 in Rule 2 is a discount effect. The other effects are coupon effects.

The Rule Engine evaluates the cart item filters and rule conditions, and applies the effects, in the following order:

  1. Rule 1

    1. Condition 1

    2. Filter 2

    3. Condition 2

      note

      Filter 2 is evaluated when the condition that references it is about to be evaluated.

    4. Effect 1

  2. Rule 2

    1. Condition 1

    2. Filter 1

    3. Filter 3

    4. Effect 1

      note

      Filter 1 and Filter 3 are evaluated when the Rule engine is about to evaluate if the discount effect can be applied.

    5. Effect 2