You are here

function uc_recurring_order_pane_checkout in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 7.2 modules/uc_recurring_order/uc_recurring_order.module \uc_recurring_order_pane_checkout()

Checkout Pane callback function.

Used to display a form in the checkout process so that customers can select recurring/repeat option.

1 string reference to 'uc_recurring_order_pane_checkout'
uc_recurring_order_checkout_pane in modules/uc_recurring_order/uc_recurring_order.module
Implementation of hook_checkout_pane().

File

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

Code

function uc_recurring_order_pane_checkout($op, &$arg1, $arg2) {
  switch ($op) {
    case 'view':
      $intervals = uc_recurring_order_get_intervals();
      if (empty($intervals)) {
        return;
      }

      // Use recurring order info from cart pane if available.
      if ($_SESSION['recurring_option']) {
        $recurring = $_SESSION['recurring_option'];
        unset($_SESSION['recurring_option']);
      }
      else {
        $recurring = $arg1->data['recurring_option'];
      }
      $description = t('Select to have this order automatically repeat.');
      $contents['recurring_option'] = array(
        '#type' => 'select',
        '#title' => t('Recurring Order'),
        '#default_value' => $recurring,
        '#options' => $intervals,
      );
      return array(
        'description' => $description,
        'contents' => $contents,
      );
    case 'process':

      // Can't renew orders that include product with recurring payments.
      if (module_exists('uc_recurring_product')) {
        if ($products = uc_recurring_product_get_recurring_products_in_order($order)) {
          unset($_SESSION['recurring_option']);
          drupal_set_message(t('Unable to create recurring order when it contains recurring products'), 'warning');
          return FALSE;
        }
      }
      $recurring = $arg2['recurring_option'];
      $next_renewal = strtotime('+' . $recurring);
      if ($next_renewal > time()) {
        $arg1->data['recurring_option'] = $recurring;
      }
      else {
        unset($_SESSION['recurring_option']);
      }
      return TRUE;
    case 'review':
      if ($arg1->data['recurring_option']) {
        $next_renewal = strtotime('+' . $arg1->data['recurring_option']);
        $review[] = array(
          'title' => t('Recurring Order'),
          'data' => t('Your next order after this will occur on @next.', array(
            '@recurring' => $arg1->data['recurring_option'],
            '@next' => format_date($next_renewal, 'short'),
          )),
        );
      }
      return $review;
  }
}