diff --git a/shipping/uc_quote/uc_quote.module b/shipping/uc_quote/uc_quote.module index 96468cb..d6e065e 100644 --- a/shipping/uc_quote/uc_quote.module +++ b/shipping/uc_quote/uc_quote.module @@ -785,6 +785,9 @@ function uc_order_pane_quotes($op, $order, &$form = NULL, &$form_state = NULL) { '#type' => 'submit', '#value' => t('Apply to order'), '#submit' => array('uc_quote_apply_quote_to_order'), + '#ajax' => array( + 'callback' => 'uc_quote_order_apply_rate', + ), ); } @@ -810,7 +813,7 @@ function uc_quote_order_pane_quotes_submit($form, &$form_state) { */ function uc_quote_apply_quote_to_order($form, &$form_state) { if (isset($form_state['values']['quotes']['quote_option'])) { - if ($order = $form_state['build_info']['args'][0]) { + 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]; @@ -838,6 +841,7 @@ function uc_quote_apply_quote_to_order($form, &$form_state) { // Update line items. $order->line_items = uc_order_load_line_items($order); + $form_state['rebuild'] = TRUE; } } } @@ -983,6 +987,23 @@ function uc_quote_order_returned_rates($form, $form_state) { } /** +* Hide shipping rates after apply. +*/ +function uc_quote_order_apply_rate($form, $form_state) { + // Hide shipping rates after apply. + $reset = array( + '#tree' => TRUE, + '#prefix' => '
', + '#suffix' => '
', + ); + $commands[] = ajax_command_replace('#quote', drupal_render($reset)); + $commands[] = ajax_command_replace('#order-line-items', drupal_render($form['line_items'])); + $commands[] = ajax_command_prepend('#quote', theme('status_messages')); + + return array('#type' => 'ajax', '#commands' => $commands); +} + +/** * Displays the returned shipping rates. * * @param $variables