public function Shipment::getPackageType in Commerce Shipping 8.2
Gets the package type.
Return value
\Drupal\commerce_shipping\Plugin\Commerce\PackageType\PackageTypeInterface|null The shipment package type, or NULL if unknown.
Overrides ShipmentInterface::getPackageType
2 calls to Shipment::getPackageType()
- Shipment::prepareFields in src/
Entity/ Shipment.php - Ensures that the package_type and weight fields are populated.
- Shipment::recalculateWeight in src/
Entity/ Shipment.php - Recalculates the shipment's weight.
File
- src/
Entity/ Shipment.php, line 141
Class
- Shipment
- Defines the shipment entity class.
Namespace
Drupal\commerce_shipping\EntityCode
public function getPackageType() {
if (!$this
->get('package_type')
->isEmpty()) {
$package_type_id = $this
->get('package_type')->value;
$package_type_manager = \Drupal::service('plugin.manager.commerce_package_type');
return $package_type_manager
->createInstance($package_type_id);
}
}