You are here

function uc_paypal_ec_review_form in Ubercart 6.2

Same name and namespace in other branches
  1. 5 payment/uc_paypal/uc_paypal.module \uc_paypal_ec_review_form()
  2. 7.3 payment/uc_paypal/uc_paypal.pages.inc \uc_paypal_ec_review_form()
1 string reference to 'uc_paypal_ec_review_form'
uc_paypal_ec_review in payment/uc_paypal/uc_paypal.pages.inc

File

payment/uc_paypal/uc_paypal.pages.inc, line 256
Paypal administration menu items.

Code

function uc_paypal_ec_review_form($form_state, $order) {
  if (module_exists('uc_quote') && variable_get('uc_paypal_ec_review_shipping', TRUE) && uc_order_is_shippable($order)) {
    $result = uc_checkout_pane_quotes('view', $order, NULL);
    $form['panes']['quotes'] = array(
      '#type' => 'fieldset',
      '#title' => t('Calculate shipping'),
      '#collapsible' => FALSE,
    );
    $form['panes']['quotes'] += $result['contents'];
    $form['panes']['quotes']['quote_button']['#value'] = t('Click to refresh shipping options');
    $form['panes']['quotes']['quote_div'] = array(
      '#value' => '<div id="quote"></div>',
    );

    // small hack; automatically looks for shipping quotes on page load
    drupal_add_js("\$(document).ready(function() { \$(' #edit-quote-button').click(); });", 'inline');

    // Fake the checkout form delivery information.
    $form['delivery_first_name'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_first_name,
    );
    $form['delivery_last_name'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_last_name,
    );
    $form['delivery_company'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_company,
    );
    $form['delivery_street1'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_street1,
    );
    $form['delivery_street2'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_street2,
    );
    $form['delivery_city'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_city,
    );
    $form['delivery_postal_code'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_postal_code,
    );
    $form['delivery_phone'] = array(
      '#type' => 'hidden',
      '#value' => $order->delivery_phone,
    );
    $form['delivery_zone'] = array(
      '#type' => 'select',
      '#options' => drupal_map_assoc(array(
        $order->delivery_zone,
      )),
      '#default_value' => $order->delivery_zone,
      '#attributes' => array(
        'style' => 'display: none;',
      ),
    );
    $form['delivery_country'] = array(
      '#type' => 'select',
      '#options' => drupal_map_assoc(array(
        $order->delivery_country,
      )),
      '#default_value' => $order->delivery_country,
      '#attributes' => array(
        'style' => 'display: none;',
      ),
    );
    $form['shippable'] = array(
      '#type' => 'hidden',
      '#value' => 'true',
    );
  }
  if (variable_get('uc_paypal_ec_review_company', TRUE)) {
    $form['delivery_company'] = array(
      '#type' => 'textfield',
      '#title' => uc_get_field_name('company'),
      '#description' => uc_order_is_shippable($order) ? t('Leave blank if shipping to a residence.') : '',
      '#default_value' => $order->delivery_company,
    );
  }
  if (variable_get('uc_paypal_ec_review_phone', TRUE)) {
    $form['delivery_phone'] = array(
      '#type' => 'textfield',
      '#title' => t('Contact phone number'),
      '#default_value' => $order->delivery_phone,
      '#size' => 24,
    );
  }
  if (variable_get('uc_paypal_ec_review_comment', TRUE)) {
    $form['order_comments'] = array(
      '#type' => 'textarea',
      '#title' => t('Order comments'),
      '#description' => t('Special instructions or notes regarding your order.'),
      '#wysiwyg' => FALSE,
    );
  }
  if (empty($form)) {
    drupal_goto('cart/echeckout/submit');
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Continue checkout'),
  );
  return $form;
}