You are here

function commerce_recurring_update_7001 in Commerce Recurring Framework 7

Implements hook_update_N Adds the payment status field to the recurring order

File

./commerce_recurring.install, line 296

Code

function commerce_recurring_update_7001() {

  // Get the field details
  $field_name = 'commerce_recurring_payment';
  $field = field_info_field($field_name);
  $field_details = _commerce_recurring_installed_fields();
  $field_detail = $field_details[$field_name];
  if (empty($field)) {
    $field = field_create_field($field_detail);
  }
  $instance_details = _commerce_recurring_installed_instances();
  $instance_detail = $instance_details[$field_name];

  // Look for existing instance.
  $instance = field_info_instance($instance_detail['entity_type'], $field_name, $instance_detail['bundle']);
  if (empty($instance)) {
    field_create_instance($instance_detail);
  }

  // We also make sure commerce_cardonfile is enabled
  include_once './includes/install.inc';

  //Refresh module list
  module_list(TRUE);
  system_rebuild_module_data();

  //Enable card on file
  module_enable(array(
    'commerce_cardonfile',
  ));
  return t('Added payment status field to the recurring order type. If you have existing recurring orders, please set their payment processing status to unprocessed.');
}