public function ProfileFieldCopy::supportsForm in Commerce Shipping 8.2
Gets whether the given inline form is supported.
Confirms that:
- The inline form is used for billing information.
- The inline form is embedded on a shippable order's page.
Parameters
array $inline_form: The inline form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
bool TRUE if the element can be attached, FALSE otherwise.
Overrides ProfileFieldCopyInterface::supportsForm
File
- src/
ProfileFieldCopy.php, line 51
Class
- ProfileFieldCopy
- Default implementation of profile field copying ("Billing same as shipping").
Namespace
Drupal\commerce_shippingCode
public function supportsForm(array &$inline_form, FormStateInterface $form_state) {
if (!isset($inline_form['#profile_scope']) || $inline_form['#profile_scope'] != 'billing') {
return FALSE;
}
$order = static::getOrder($form_state);
if (!$order) {
// The inline form is being used outside of an order context
// (e.g. the payment method add/edit screen).
return FALSE;
}
if (!$order
->hasField('shipments')) {
// The order is not shippable.
return FALSE;
}
return TRUE;
}