You are here

public function BillingInformation::buildPaneForm in Commerce Core 8.2

Builds the pane form.

Parameters

array $pane_form: The pane form, containing the following basic properties:

  • #parents: Identifies the position of the pane form in the overall parent form, and identifies the location where the field values are placed within $form_state->getValues().

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

array $complete_form: The complete form structure.

Overrides CheckoutPaneInterface::buildPaneForm

File

modules/checkout/src/Plugin/Commerce/CheckoutPane/BillingInformation.php, line 81

Class

BillingInformation
Provides the billing information pane.

Namespace

Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane

Code

public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
  $profile = $this->order
    ->getBillingProfile();
  if (!$profile) {
    $profile_storage = $this->entityTypeManager
      ->getStorage('profile');
    $profile = $profile_storage
      ->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,
  ], $profile);
  $pane_form['profile'] = [
    '#parents' => array_merge($pane_form['#parents'], [
      'profile',
    ]),
    '#inline_form' => $inline_form,
  ];
  $pane_form['profile'] = $inline_form
    ->buildInlineForm($pane_form['profile'], $form_state);
  return $pane_form;
}