You are here

protected function PaymentInformation::buildBillingProfileForm in Commerce Core 8.2

Builds the billing profile form.

Parameters

array $pane_form: The pane form.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the parent form.

Return value

array The modified pane form.

1 call to PaymentInformation::buildBillingProfileForm()
PaymentInformation::buildPaneForm in modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php
Builds the pane form.

File

modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php, line 281

Class

PaymentInformation
Provides the payment information pane.

Namespace

Drupal\commerce_payment\Plugin\Commerce\CheckoutPane

Code

protected function buildBillingProfileForm(array $pane_form, FormStateInterface $form_state) {
  $billing_profile = $this->order
    ->getBillingProfile();
  if (!$billing_profile) {
    $billing_profile = $this->entityTypeManager
      ->getStorage('profile')
      ->create([
      'type' => 'customer',
      'uid' => 0,
    ]);
  }
  $inline_form = $this->inlineFormManager
    ->createInstance('customer_profile', [
    'profile_scope' => 'billing',
    'available_countries' => $this->order
      ->getStore()
      ->getBillingCountries(),
    'address_book_uid' => $this->order
      ->getCustomerId(),
    // Don't copy the profile to address book until the order is placed.
    'copy_on_save' => FALSE,
  ], $billing_profile);
  $pane_form['billing_information'] = [
    '#parents' => array_merge($pane_form['#parents'], [
      'billing_information',
    ]),
    '#inline_form' => $inline_form,
  ];
  $pane_form['billing_information'] = $inline_form
    ->buildInlineForm($pane_form['billing_information'], $form_state);
  return $pane_form;
}