You are here

function ca_remove_action in Ubercart 6.2

Remove an action from a predicate.

Parameters

$pid: The ID of the predicate to remove the action from.

$index: The index of the action to remove.

Return value

An array representing the full, updated predicate.

1 call to ca_remove_action()
ca_actions_form_remove_action_submit in ca/ca.admin.inc
Remove action submit handler.

File

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

Code

function ca_remove_action($pid, $index) {
  $actions = array();

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

  // Build a new actions array, leaving out the one marked for removal.
  foreach ($predicate['#actions'] as $key => $action) {
    if ($key != $index) {
      $actions[] = $action;
    }
  }

  // Update, save, and return the predicate.
  $predicate['#actions'] = $actions;
  ca_save_predicate($predicate);
  return $predicate;
}