You are here

function uc_order_pane_quotes in Ubercart 7.3

Same name and namespace in other branches
  1. 5 shipping/uc_quote/uc_quote.module \uc_order_pane_quotes()
  2. 6.2 shipping/uc_quote/uc_quote.module \uc_order_pane_quotes()

Shipping quote order pane callback.

See also

uc_quote_order_pane_quotes_submit()

uc_quote_apply_quote_to_order()

1 string reference to 'uc_order_pane_quotes'
uc_quote_uc_order_pane in shipping/uc_quote/uc_quote.module
Implements hook_uc_order_pane().

File

shipping/uc_quote/uc_quote.module, line 663
The controller module for fulfillment modules that process physical goods.

Code

function uc_order_pane_quotes($op, $order, &$form = NULL, &$form_state = NULL) {
  switch ($op) {
    case 'edit-form':
      $form['quotes']['quote_button'] = array(
        '#type' => 'submit',
        '#value' => t('Get shipping quotes'),
        '#submit' => array(
          'uc_quote_order_pane_quotes_submit',
        ),
        '#ajax' => array(
          'callback' => 'uc_quote_replace_order_quotes',
          'wrapper' => 'quote',
          'effect' => 'slide',
          'progress' => array(
            'type' => 'bar',
            'message' => t('Receiving quotes...'),
          ),
        ),
      );
      $form['quotes']['quotes'] = array(
        '#tree' => TRUE,
        '#prefix' => '<div id="quote">',
        '#suffix' => '</div>',
      );
      if (!empty($form_state['quote_requested'])) {

        // Rebuild form products, from uc_order_edit_form_submit()
        $order->products = array();
        if (isset($form_state['values']['products']) && is_array($form_state['values']['products'])) {
          foreach ($form_state['values']['products'] as $product) {
            $product['data'] = unserialize($product['data']);
            $product = (object) $product;
            $order->products[] = $product;
          }
        }
        $form['quotes']['quotes'] += uc_quote_build_quote_form($order);
        $form['quotes']['quotes']['add_quote'] = array(
          '#type' => 'submit',
          '#value' => t('Apply to order'),
          '#submit' => array(
            'uc_quote_apply_quote_to_order',
          ),
          '#ajax' => array(
            'callback' => 'uc_quote_order_update_rates',
            'effect' => 'fade',
            'progress' => array(
              'type' => 'throbber',
              'message' => t('Applying quotes...'),
            ),
          ),
        );
      }
      $form_state['uc_ajax']['uc_quote']['ship_to][delivery_country'] = array(
        'quote' => 'uc_quote_replace_order_quotes',
      );
      return $form;
    case 'edit-theme':
      return drupal_render($form['quotes']);
  }
}