function uc_recurring_update_6012 in UC Recurring Payments and Subscriptions 7.2
Same name and namespace in other branches
- 6.2 uc_recurring.install \uc_recurring_update_6012()
Add another table to track order relationships.
File
- ./
uc_recurring.install, line 524 - Installs the Recurring Fee module.
Code
function uc_recurring_update_6012() {
$schema['uc_recurring_orders'] = array(
'fields' => array(
'original_order_id' => array(
'description' => t('The original order ID.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'renewal_order_id' => array(
'description' => t('The recurring order ID.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
);
db_create_table('uc_recurring_orders', $schema['uc_recurring_orders']);
// Load all the recurring fees and build the uc_recurring_orders table from data found.
$result = db_query('SELECT * from {uc_recurring_users}');
foreach ($result as $row) {
$row->data = unserialize($row->data);
if (!empty($row->data['recurring orders'])) {
foreach ($row->data['recurring orders'] as $order_id => $order) {
$id = db_insert('uc_recurring_orders')
->fields(array(
'original_order_id' => $row->order_id,
'renewal_order_id' => $order_id,
))
->execute();
}
}
}
}