You are here

function uc_recurring_order_uc_order in UC Recurring Payments and Subscriptions 7.2

Implements hook_uc_order().

File

modules/uc_recurring_order/uc_recurring_order.module, line 246
Provides a way to duplicate entire orders.

Code

function uc_recurring_order_uc_order($op, $order, $arg2) {
  switch ($op) {

    // TODO: Allow admin to create a recurring order from "create order" page.
    case 'submit':
      $recurring = isset($order->data['recurring_option']) ? $order->data['recurring_option'] : 0;
      $next_renewal = strtotime('+' . $recurring);
      if ($next_renewal > REQUEST_TIME && variable_get('uc_recurring_checkout_process', TRUE)) {
        if (uc_recurring_order_process_order($order, $recurring) === FALSE) {
          return array(
            array(
              'pass' => FALSE,
              'message' => t('Your order cannot be completed, because we could not process your recurring payment. Please review your payment details and contact us to complete your order if the problem persists.'),
            ),
          );
        }
      }
      break;
    case 'save':

      // Only update when this is a recurring order
      if (isset($arg1->data['recurring_option'])) {
        global $user;
        $affected = db_update('uc_recurring_users')
          ->fields(array(
          'fee_amount' => uc_order_get_total($arg1),
        ))
          ->condition('order_id', $arg1->order_id)
          ->execute();
        if ($affected > 0) {
          uc_order_comment_save($arg1->order_id, $user->uid, t('The recurring order amount was updated.'));
        }
        break;
      }
  }
}