You are here

function commerce_recurring_rules_stop_recurring in Commerce Recurring Framework 7.2

React to disable the recurring entity associated to a given entity.

1 string reference to 'commerce_recurring_rules_stop_recurring'
commerce_recurring_rules_action_info in ./commerce_recurring.rules.inc
Implements hook_rules_action_info().

File

./commerce_recurring.rules.inc, line 590
Rules integration for recurring entities.

Code

function commerce_recurring_rules_stop_recurring($wrapper) {
  switch ($wrapper->type
    ->value()) {
    case 'commerce_order':
      $recurring_entities = commerce_recurring_load_by_order($wrapper
        ->value());

      // It's very unlikely that there's more than one recurring entity
      // associated with the order but take care of that case as well.
      foreach ($recurring_entities as $recurring_entity) {
        commerce_recurring_stop_recurring($recurring_entity);
      }
      break;
    case 'commerce_recurring':
      $recurring_entity = $wrapper
        ->value();
      commerce_recurring_stop_recurring($recurring_entity);
      break;
  }
}