protected static function ProfileFieldCopy::getOrder in Commerce Shipping 8.2
Gets the order from the parent form.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\commerce_order\Entity\OrderInterface|null The order, or NULL if not found (unrecognized form).
2 calls to ProfileFieldCopy::getOrder()
- ProfileFieldCopy::getShippingProfile in src/
ProfileFieldCopy.php - Gets the shipping profile from the parent form.
- ProfileFieldCopy::supportsForm in src/
ProfileFieldCopy.php - Gets whether the given inline form is supported.
File
- src/
ProfileFieldCopy.php, line 285
Class
- ProfileFieldCopy
- Default implementation of profile field copying ("Billing same as shipping").
Namespace
Drupal\commerce_shippingCode
protected static function getOrder(FormStateInterface $form_state) {
$form_object = $form_state
->getFormObject();
if (!$form_object instanceof BaseFormIdInterface) {
return NULL;
}
$order = NULL;
if ($form_object instanceof EntityFormInterface) {
$entity = $form_object
->getEntity();
if ($entity
->getEntityTypeId() == 'commerce_order') {
$order = $entity;
}
}
elseif ($form_object
->getBaseFormId() == 'commerce_checkout_flow') {
/** @var \Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface $form_object */
$order = $form_object
->getOrder();
}
return $order;
}