You are here

public function Products::ajaxCallback in Ubercart 8.4

AJAX callback to render the order product controls.

File

uc_order/src/Plugin/Ubercart/OrderPane/Products.php, line 583

Class

Products
Manage the products an order contains.

Namespace

Drupal\uc_order\Plugin\Ubercart\OrderPane

Code

public function ajaxCallback($form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#product-controls', trim(drupal_render($form['product_controls']))));
  $status_messages = [
    '#type' => 'status_messages',
  ];
  $response
    ->addCommand(new PrependCommand('#product-controls', drupal_render($status_messages)));
  if ($form_state
    ->get('refresh_products')) {
    $response
      ->addCommand(new ReplaceCommand('#order-edit-products', trim(drupal_render($form['products']))));
    $response
      ->addCommand(new ReplaceCommand('#order-line-items', trim(drupal_render($form['line_items']))));
  }

  // Remove the field so we only refresh the admin comments item-list.
  unset($form['admin_comment_field']);
  $response
    ->addCommand(new ReplaceCommand('#order-pane-admin_comments .item-list', uc_order_pane_admin_comments('edit-theme', $form['#order'], $form, $form_state)));
  return $response;
}