You are here

public function PayPalExpressCheckout::submitExpressReviewForm in Ubercart 8.4

Form constructor for the express checkout review form.

File

payment/uc_paypal/src/Plugin/Ubercart/PaymentMethod/PayPalExpressCheckout.php, line 381

Class

PayPalExpressCheckout
Defines the PayPal Express Checkout payment method.

Namespace

Drupal\uc_paypal\Plugin\Ubercart\PaymentMethod

Code

public function submitExpressReviewForm(array $form, FormStateInterface $form_state, OrderInterface $order) {
  if (!empty($form['panes']['quotes']['quotes'])) {
    \Drupal::service('plugin.manager.uc_cart.checkout_pane')
      ->createInstance('quotes')
      ->prepare($order, $form, $form_state);
  }
  $address = $order
    ->getAddress('delivery');
  if ($this->configuration['ec_review_company']) {
    $address
      ->setCompany($form_state
      ->getValue('delivery_company'));
  }
  if ($this->configuration['ec_review_phone']) {
    $address
      ->setPhone($form_state
      ->getValue('delivery_phone'));
  }
  $order
    ->setAddress('delivery', $address);
  if ($this->configuration['ec_review_comment'] && $form_state
    ->getValue('order_comments')) {
    $this->database
      ->delete('uc_order_comments')
      ->condition('order_id', $order
      ->id())
      ->execute();
    uc_order_comment_save($order
      ->id(), 0, $form_state
      ->getValue('order_comments'), 'order');
  }
  $order
    ->save();
}