You are here

function uc_stripe_update_7202 in Ubercart Stripe 7.2

Same name and namespace in other branches
  1. 7.3 uc_stripe.install \uc_stripe_update_7202()

Move customer IDs from uc_recurring_stripe into account

File

./uc_stripe.install, line 108
Installation file for the uc_stripe module.

Code

function uc_stripe_update_7202(&$sandbox) {
  $ret = array();
  $sandbox['per_run'] = 100;

  // users per run
  $sandbox['#finished'] = 0;
  if (db_table_exists('uc_recurring_stripe')) {
    if (!isset($sandbox['progress'])) {
      $sandbox['progress'] = 0;
      $sandbox['max'] = db_query('
        SELECT COUNT(DISTINCT(u.uid))
        FROM {users} u JOIN {uc_recurring_stripe} urs
        ON (u.uid = urs.uid)
        WHERE urs.active = 1
    ')
        ->fetchField();
    }
    _uc_stripe_move_customer_id($sandbox);
    return "Updated {$sandbox['progress']} of {$sandbox['max']} uc_recurring_stripe rows into user objects";
  }
  else {
    return 'Old uc_recurring_stripe table did not exist, no action taken.';
  }
}