You are here

function ca_add_action in Ubercart 6.2

Add a new action to a predicate.

Parameters

$pid: The ID of the predicate to add the action to.

$name: The name of the action to add.

Return value

An array representing the full, updated predicate.

1 call to ca_add_action()
ca_actions_form_add_action_submit in ca/ca.admin.inc
Add action submit handler.

File

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

Code

function ca_add_action($pid, $name) {

  // Load the predicate as it is now.
  $predicate = ca_load_predicate($pid);

  // Load the action.
  $action = ca_load_action($name);

  // Abort if it did not exist.
  if (empty($action)) {
    return $predicate;
  }

  // Add the name to the action array so it's saved in the predicate.
  $action['#name'] = $name;

  // Add the action to the predicate's actions array.
  $predicate['#actions'][] = $action;

  // Save and return the updated predicate.
  ca_save_predicate($predicate);
  return $predicate;
}