public function Quotes::updateOrderRates in Ubercart 8.4
Ajax callback for applying shipping rates.
File
- shipping/
uc_quote/ src/ Plugin/ Ubercart/ OrderPane/ Quotes.php, line 168
Class
- Quotes
- Get a shipping quote for the order from a quoting module.
Namespace
Drupal\uc_quote\Plugin\Ubercart\OrderPaneCode
public function updateOrderRates($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
// Update shipping line item.
if ($form_state
->has('uc_quote')) {
$lid = $form_state
->get([
'uc_quote',
'lid',
]);
$form['line_items'][$lid]['title']['#value'] = $form_state
->get([
'uc_quote',
'title',
]);
$form['line_items'][$lid]['amount']['#value'] = $form_state
->get([
'uc_quote',
'amount',
]);
}
$response
->addCommand(new ReplaceCommand('#order-line-items', trim(drupal_render($form['line_items']))));
// Reset shipping form.
$response
->addCommand(new ReplaceCommand('#quote', trim(drupal_render($form['quotes']['quotes']))));
$status_messages = [
'#type' => 'status_messages',
];
$response
->addCommand(new PrependCommand('#quote', drupal_render($status_messages)));
return $response;
}