protected function ShippingInformation::canCalculateRates in Commerce Shipping 8.2
Gets whether shipping rates can be calculated for the given profile.
Ensures that a required shipping address is present and valid.
Parameters
\Drupal\profile\Entity\ProfileInterface $profile: The profile.
Return value
bool TRUE if shipping rates can be calculated, FALSE otherwise.
1 call to ShippingInformation::canCalculateRates()
- ShippingInformation::buildPaneForm in src/
Plugin/ Commerce/ CheckoutPane/ ShippingInformation.php - Builds the pane form.
File
- src/
Plugin/ Commerce/ CheckoutPane/ ShippingInformation.php, line 549
Class
- ShippingInformation
- Provides the shipping information pane.
Namespace
Drupal\commerce_shipping\Plugin\Commerce\CheckoutPaneCode
protected function canCalculateRates(ProfileInterface $profile) {
if (!empty($this->configuration['require_shipping_profile'])) {
$violations = $profile
->get('address')
->validate();
return count($violations) === 0;
}
return TRUE;
}