function uc_quote_apply_quote_to_order in Ubercart 7.3
Ajax callback: Manually applies a shipping quote to an order.
1 string reference to 'uc_quote_apply_quote_to_order'
- uc_order_pane_quotes in shipping/
uc_quote/ uc_quote.module - Shipping quote order pane callback.
File
- shipping/
uc_quote/ uc_quote.module, line 738 - The controller module for fulfillment modules that process physical goods.
Code
function uc_quote_apply_quote_to_order($form, &$form_state) {
if (isset($form_state['values']['quotes']['quote_option'])) {
if ($order = $form_state['order']) {
$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']);
$form_state['uc_quote'] = array(
'lid' => $lid,
'title' => $label,
'amount' => $order->quote['rate'],
);
}
else {
uc_order_line_item_add($order->order_id, 'shipping', $label, $order->quote['rate']);
}
// Save selected shipping.
uc_quote_uc_order('save', $order, '');
// Update line items.
$order->line_items = uc_order_load_line_items($order);
$form_state['order'] = $order;
$form_state['rebuild'] = TRUE;
$form_state['quote_requested'] = FALSE;
}
}
}