You are here

function uc_paypal_ec_review_form_submit in Ubercart 7.3

Same name and namespace in other branches
  1. 5 payment/uc_paypal/uc_paypal.module \uc_paypal_ec_review_form_submit()
  2. 6.2 payment/uc_paypal/uc_paypal.pages.inc \uc_paypal_ec_review_form_submit()

File

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

Code

function uc_paypal_ec_review_form_submit($form, &$form_state) {
  $order = uc_order_load($_SESSION['cart_order']);
  if (!empty($form_state['values']['shippable'])) {
    $quote_option = explode('---', $form_state['values']['quotes']['quote_option']);
    $order->quote['method'] = $quote_option[0];
    $order->quote['accessorials'] = $quote_option[1];
    $methods = uc_quote_methods();
    $method = $methods[$quote_option[0]];
    $label = $method['quote']['accessorials'][$quote_option[1]];
    $quote_option = $form_state['values']['quotes']['quote_option'];
    $order->quote['rate'] = $form_state['values']['quotes'][$quote_option]['rate'];
    $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = :id AND type = :type", array(
      ':id' => $order->order_id,
      ':type' => 'shipping',
    ));
    if ($lid = $result
      ->fetchField()) {
      uc_order_update_line_item($lid, $label, $order->quote['rate']);
    }
    else {
      uc_order_line_item_add($order->order_id, 'shipping', $label, $order->quote['rate']);
    }
  }
  if (variable_get('uc_paypal_ec_review_company', TRUE)) {
    $order->delivery_company = $form_state['values']['delivery_company'];
  }
  if (variable_get('uc_paypal_ec_review_phone', TRUE)) {
    $order->delivery_phone = $form_state['values']['delivery_phone'];
  }
  if (variable_get('uc_paypal_ec_review_comment', TRUE)) {
    db_delete('uc_order_comments')
      ->condition('order_id', $order->order_id)
      ->execute();
    uc_order_comment_save($order->order_id, 0, $form_state['values']['order_comments'], 'order');
  }
  uc_order_save($order);
  $form_state['redirect'] = 'cart/echeckout/submit';
}