You are here

function commerce_registration_set_state in Commerce Registration 7.2

Same name and namespace in other branches
  1. 7.3 commerce_registration.rules.inc \commerce_registration_set_state()

Action callback.

Sets all registrations on an order to a given state.

Related topics

1 string reference to 'commerce_registration_set_state'
commerce_registration_default_rules_configuration in ./commerce_registration.rules_defaults.inc
Implements hook_default_rules_configuration().

File

./commerce_registration.rules.inc, line 175
Commerce Registration rules file.

Code

function commerce_registration_set_state($order, $registration_state) {

  // The rules action specifies this parameter, but it can be a multiple
  // for some reason. The majority of the time it will be a single string
  if (is_array($registration_state)) {
    $registration_state = reset($registration_state);
  }
  $regs = db_select('registration', 'r')
    ->fields('r')
    ->condition('order_id', $order->order_id)
    ->execute();
  foreach ($regs as $row) {
    $registration = registration_load($row->registration_id);
    $registration->state = $registration_state;
    registration_save($registration);
  }
}