You are here

function ca_pull_trigger in Ubercart 6.2

Pull a trigger and evaluate any predicates associated with that trigger.

Parameters

...: Accepts a variable number of arguments. The first should always be the string name of the trigger to pull with any additional arguments being the arguments expected by the trigger and used for evaluation.

Return value

TRUE or FALSE indicating if at least one predicate was evaluated.

10 calls to ca_pull_trigger()
hook_line_item_alter in docs/hooks.php
Alters a line item on an order when the order is loaded.
uc_cart_complete_sale in uc_cart/uc_cart.module
Completes a sale, including adjusting order status and creating user account.
uc_file_action_order_renew in uc_file/uc_file.ca.inc
Renews an orders product files.
uc_order_delete in uc_order/uc_order.module
Deletes an order and tells other modules to do the same.
uc_order_update_status in uc_order/uc_order.module
Update an order's status as long as no one objects.

... See full list

File

ca/ca.module, line 162
This is a demonstration module for the new conditional actions API.

Code

function ca_pull_trigger() {
  $args = func_get_args();
  $trigger = array_shift($args);

  // Load the data for the specified trigger.
  $trigger_data = ca_load_trigger($trigger);

  // Fail if the specified trigger doesn't exist.
  if (!$trigger_data) {
    return FALSE;
  }

  // Load any predicates associated with the trigger.
  $predicates = ca_load_trigger_predicates($trigger);

  // Fail if we didn't find any predicates.
  if (!$predicates || count($predicates) == 0) {
    return FALSE;
  }

  // Prepare the arguments for evaluation.
  $arguments = ca_parse_trigger_args($trigger_data, $args);

  // Fail if we didn't receive the right type of or enough arguments.
  if (!$arguments) {
    return FALSE;
  }

  // Loop through the predicates and evaluate them one by one.
  foreach ($predicates as $pid => $predicate) {

    // If all of a predicate's conditions evaluate to TRUE...
    if (ca_evaluate_conditions($predicate, $arguments)) {

      // Then perform its actions.
      ca_perform_actions($predicate, $arguments);
    }
  }
  return TRUE;
}