protected function FedEx::splitPackages in Commerce FedEx 8
Queries plugins to split shipments into fedex packages.
Parameters
\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment to split.
Return value
array An array of arrays or shipment items.
2 calls to FedEx::splitPackages()
- FedEx::getRequestedPackageLineItemsAllInOne in src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php - Gets package line items for PACKAGE_ALL_IN_ONE strategy.
- FedEx::getRequestedPackageLineItemsCalculate in src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php - Gets package line items for PACKAGE_CALCULATE strategy.
File
- src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php, line 843
Class
- FedEx
- Provides the FedEx shipping method.
Namespace
Drupal\commerce_fedex\Plugin\Commerce\ShippingMethodCode
protected function splitPackages(ShipmentInterface $shipment) {
$packages = [
$shipment
->getItems(),
];
foreach ($this->fedExServiceManager
->getDefinitions() as $plugin_id => $definition) {
/** @var \Drupal\commerce_fedex\Plugin\Commerce\FedEx\FedExPluginInterface $plugin */
$plugin = $this->plugins
->get($plugin_id);
$new_packages = [];
foreach ($packages as $package) {
$new_packages = array_merge($new_packages, $plugin
->splitPackage($package, $shipment));
}
$packages = array_filter($new_packages);
}
return $packages;
}