function _uc_stripe_move_customer_id in Ubercart Stripe 6.2
Same name and namespace in other branches
- 7.3 uc_stripe.install \_uc_stripe_move_customer_id()
- 7.2 uc_stripe.install \_uc_stripe_move_customer_id()
Move customer ids from uc_recurring_stripe into user account
1 call to _uc_stripe_move_customer_id()
- uc_stripe_update_6202 in ./
uc_stripe.install - Move customer IDs from uc_recurring_stripe into account
File
- ./
uc_stripe.install, line 125 - Installation file for the uc_stripe module.
Code
function _uc_stripe_move_customer_id(&$sandbox) {
$ret = array();
$query = '
SELECT rfid, uid, customer_id
FROM {uc_recurring_stripe} urs
WHERE urs.rfid IN (
SELECT max(sq.rfid) FROM {uc_recurring_stripe} sq WHERE sq.uid=urs.uid AND active=1
)
';
$result = db_query_range($query, $sandbox['progress'], $sandbox['per_run']);
$count = $visited = 0;
while ($item = db_fetch_array($result)) {
$account = user_load($item['uid']);
$visited++;
$ret[] = array(
'success' => TRUE,
'query' => "Updated account {$account->name} uid={$account->uid}",
);
if (empty($account->uc_stripe_customer_id)) {
user_save($account, array(
'uc_stripe_customer_id' => $item['customer_id'],
));
$count++;
}
}
$sandbox['progress'] += $sandbox['per_run'];
if ($sandbox['progress'] <= $sandbox['max']) {
$ret['#finished'] = $sandbox['progress'] / $sandbox['max'];
}
return $ret;
}