You are here

public function DryIcePlugin::splitPackage in Commerce FedEx 8

Function splitPackage.

Parameters

array $shipment_items: An Array of shipment items.

\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The Shipment.

Return value

array An array of arrays of shipment items.

Overrides FedExPluginBase::splitPackage

File

modules/dry_ice/src/Plugin/Commerce/FedEx/DryIcePlugin.php, line 189

Class

DryIcePlugin
Provides the Fedex Dry Ice Service.

Namespace

Drupal\commerce_fedex_dry_ice\Plugin\Commerce\FedEx

Code

public function splitPackage(array $shipment_items, ShipmentInterface $shipment) {
  $type = $this
    ->getType($shipment);
  $packages = [
    static::NOT_DRY_ICE => [],
    static::DRY_ICE => [],
  ];
  foreach ($shipment_items as $shipment_item) {
    if ($this
      ->isDryIceItem($shipment_item, $type)) {
      $packages[static::DRY_ICE][] = $shipment_item;
    }
    else {
      $packages[static::NOT_DRY_ICE][] = $shipment_item;
    }
  }
  return $packages;
}