You are here

protected static function ProfileFieldCopy::getShippingProfile in Commerce Shipping 8.2

Gets the shipping profile from the parent form.

Parameters

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

Return value

\Drupal\profile\Entity\ProfileInterface|null The shipping profile, or NULL if not found.

2 calls to ProfileFieldCopy::getShippingProfile()
ProfileFieldCopy::alterForm in src/ProfileFieldCopy.php
Alters the inline form.
ProfileFieldCopy::submitForm in src/ProfileFieldCopy.php
Submits the inline form.

File

src/ProfileFieldCopy.php, line 262

Class

ProfileFieldCopy
Default implementation of profile field copying ("Billing same as shipping").

Namespace

Drupal\commerce_shipping

Code

protected static function getShippingProfile(FormStateInterface $form_state) {
  if ($form_state
    ->has('shipping_profile')) {

    // Shipping information on the same step as the billing information.
    $shipping_profile = $form_state
      ->get('shipping_profile');
  }
  else {
    $order = static::getOrder($form_state);
    $profiles = $order
      ->collectProfiles();
    $shipping_profile = $profiles['shipping'] ?? NULL;
  }
  return $shipping_profile;
}