You are here

function hook_inline_conditions_info in Inline Conditions 7

Defines inline conditions.

Inline Conditions are configured and added through a field attached to the parent entity (discount, shipping rate, etc) based on which the rule is built. When the rule is being built, the module providing the parent entity type calls inline_conditions_build_rule, which in turn calls the build callback of each configured inline condition. Based on the user provided configuration, the build callback adds an actual rules condition to the passed rule.

Supported keys:

  • label: The human readable label, shown in the UI (field widget).
  • entity type: The type of the entity available to the rule, on which the condition can operate. This is the main criteria on which conditions are selected for showing in the field widget.
  • rule condition name: (Optional) Rule condition machine name. This rule condition will be use instead of the inline condition name. If this key is set, the build callback is optional.
  • parent entity type: (Optional) The type of the parent entity type (that contains the Inline Conditions field), used to further limit the availability of the condition (so a condition could choose to be shown only for Order Discounts, but not Shipping Services, even though both operate on the same entity type -> commerce_order).
  • callbacks: An array of callbacks:
    • configure: (Optional) Returns a configuration form embedded into the field widget, and used to configure the inline condition. The following list of parameters will be passed to the configure callback function:

      • condition_settings (Array): an array containing all configured settings; typically this will match the values of the form elements defined in the 'configure' callback. It should be transformed into an array of parameter values as the rules condition needs them.
      • instance (Array): The field instance array (which includes the entity information that is related to the condition, such as the ID).
      • delta (Int): The current field delta defined as an integer.
    • build: [Do not use if rule condition name is set] Gets the rule and any settings added by the configure callback, then builds and adds an actual rules condition to the rule. Also, if the rule condition name key is set, this parameter is no longer available.
1 function implements hook_inline_conditions_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

inline_conditions_inline_conditions_info in ./inline_conditions.inline_conditions.inc
Implements hook_inline_conditions_info().
1 invocation of hook_inline_conditions_info()
inline_conditions_get_info in ./inline_conditions.module
Returns the info array of a condition.

File

./inline_conditions.api.php, line 48
Hooks provided by the Inline Conditions module.

Code

function hook_inline_conditions_info() {
  $conditions = array();
  $conditions['inline_conditions_order_total'] = array(
    'label' => t('Orders over'),
    'entity type' => 'commerce_order',
    //'rule condition name' => 'data_is'
    'callbacks' => array(
      'configure' => 'inline_conditions_order_total_configure',
      'build' => 'inline_conditions_order_total_build',
    ),
  );
  return $conditions;
}