To add conditional rules that integrate with a loop type, register them with the Tangible Logic module.
The goal is to allow building conditions in an intuitive way, close to natural English.
In practice, the conditional UI is typically used on the admin side to control visibility of templates or builder widgets, based on user-constructed rule groups.
- Core conditional rules defined in the Template module
- Documentation for the Logic module
First, get an instance of the Logic module.
$logic = tangible_logic();
This can be done within or after the
Then call the
$logic->extend_rules_by_category( 'woocommerce', $rules, $evaluator );
It accepts the following arguments:
Category name (string)
Used to group rule definitions and generate documentation
Rule definitions (array)
This is the same as the
fieldsproperty in the conditions config for the Logic module.
Each rule definition is an associative array with:
Evaluator (anonymous function, or function name as string)
This is the same as the evaluator for the Logic module.
It is a function that receives a rule to evaluate, and returns true or false (boolean).