Skip to content Skip to main navigation Skip to footer

Order of Rules Execution

Order of Rules Execution

Pricing rules are executed based on the ‘Order’ parameter, which you set in the ‘Post Attributes’ metabox visible on the right side of the window when editing the rule. If multiple rules in the system meet their conditions, the one with the highest ‘Order’ parameter takes precedence and is executed first.

See screenshot

Good to Know

If multiple rules in the system meet their conditions and have the same ‘Order’ parameter, such as when it’s unset or set to ‘0’, the order of rule execution will be unspecified.

Next Rule Processing

The ‘Next Rule Processing’ option is found in the ‘Options’ tab when editing a rule. When set to ‘Enable’, after executing a rule, the algorithm revisits the list of rules to find another whose conditions are met. Conversely, when set to ‘Disable’, the algorithm proceeds to the next lower level of rule execution, searching for rules at that level. If all rules are at the same level in your configuration, the algorithm will terminate.

See screenshot

Rule Levels

Rule levels dictate the order in which rules are executed, akin to different floors in a building. By default, all rules are at the highest level, ‘9999’. Lower values represent lower levels, down to ‘-9999’. The system first checks the highest level for a matching rule based on the ‘Order’ parameter. If found, it applies the defined prices and checks the ‘Next Rule Processing’ setting. If set to ‘Enable’, it continues searching for rules at the same level; if set to ‘Disable’, it moves down a level and repeats the process. The ‘Rule Level’ option is located in the ‘Options’ tab visible when editing a rule and its use is optional.

Finding and Executing Rules

To systematize the above information, the step-by-step description below presents the operating algorithm.

  1. The program begins by operating at the highest defined ‘Rule Level’. If not specified in any rule, the default assumed level is ‘9999’.
  2. The program searches for a matching rule with the highest ‘Order’ parameter. If found, it applies the prices from this rule and checks the ‘Next Rule Processing’ setting.
  3. If ‘Enable’ is set, the program seeks another matching rule with a lower ‘Order’ parameter. Upon finding one, it executes the rule and adopts the price level from it.
  4. If ‘Disable’ is set, the program concludes this cycle. It then checks if there are rules at a lower level (i.e., with a ‘Rule Level’ lower than ‘9999’). If such rules exist, it moves to the lower level and repeats the cycle. If not, the program terminates.

Important!

The price level is determined by the last matching rule executed.

Pricing Rules Execution Flowchart

The following flowchart illustrates the algorithm used to executing rules in the plugin.

Summary

Document version: 1.0
Last updated: April 17, 2024
Plugin version: 6.8+

Was This Article Helpful?

Related Articles