commerce-8.x-2.8/modules/checkout/src/Plugin/Commerce/CheckoutPane/BillingInformation.php
modules/checkout/src/Plugin/Commerce/CheckoutPane/BillingInformation.php
<?php namespace Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane; use Drupal\Core\Form\FormStateInterface; /** * Provides the billing information pane. * * @CommerceCheckoutPane( * id = "billing_information", * label = @Translation("Billing information"), * default_step = "order_information", * wrapper_element = "fieldset", * ) */ class BillingInformation extends CheckoutPaneBase implements CheckoutPaneInterface { /** * {@inheritdoc} */ public function buildPaneSummary() { $summary = []; if ($billing_profile = $this->order->getBillingProfile()) { $profile_view_builder = $this->entityTypeManager->getViewBuilder('profile'); $summary = $profile_view_builder->view($billing_profile, 'default'); } return $summary; } /** * {@inheritdoc} */ public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) { $store = $this->order->getStore(); $billing_profile = $this->order->getBillingProfile(); if (!$billing_profile) { $profile_storage = $this->entityTypeManager->getStorage('profile'); $billing_profile = $profile_storage->create([ 'type' => 'customer', 'uid' => $this->order->getCustomerId(), ]); } $pane_form['profile'] = [ '#type' => 'commerce_profile_select', '#default_value' => $billing_profile, '#default_country' => $store->getAddress()->getCountryCode(), '#available_countries' => $store->getBillingCountries(), ]; return $pane_form; } /** * {@inheritdoc} */ public function submitPaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) { $this->order->setBillingProfile($pane_form['profile']['#profile']); } }