You are here

public function OrderCommentsPane::view in Ubercart 8.4

Returns the contents of a checkout pane.

Parameters

\Drupal\uc_order\OrderInterface $order: The order that is being processed.

array $form: The checkout form array.

\Drupal\Core\Form\FormStateInterface $form_state: The checkout form state array.

Return value

array A form array, with an optional '#description' key to provide help text for the pane.

Overrides CheckoutPanePluginInterface::view

File

uc_cart/src/Plugin/Ubercart/CheckoutPane/OrderCommentsPane.php, line 23

Class

OrderCommentsPane
Allows a customer to make comments on the order.

Namespace

Drupal\uc_cart\Plugin\Ubercart\CheckoutPane

Code

public function view(OrderInterface $order, array $form, FormStateInterface $form_state) {
  $build['#description'] = $this
    ->t('Use this area for special instructions or questions regarding your order.');
  if ($order
    ->id()) {
    $default = \Drupal::database()
      ->query('SELECT message FROM {uc_order_comments} WHERE order_id = :id', [
      ':id' => $order
        ->id(),
    ])
      ->fetchField();
  }
  else {
    $default = NULL;
  }
  $build['comments'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Order comments'),
    '#default_value' => $default,
  ];
  return $build;
}