You are here

public function PackerManager::pack in Commerce Shipping 8.2

Packs the given order.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

\Drupal\profile\Entity\ProfileInterface $shipping_profile: The shipping profile.

Return value

\Drupal\commerce_shipping\ProposedShipment[] The proposed shipments.

Overrides PackerManagerInterface::pack

1 call to PackerManager::pack()
PackerManager::packToShipments in src/PackerManager.php
Packs the given order and populates the given shipments.

File

src/PackerManager.php, line 53

Class

PackerManager

Namespace

Drupal\commerce_shipping

Code

public function pack(OrderInterface $order, ProfileInterface $shipping_profile) {
  $proposed_shipments = [];
  foreach ($this->packers as $packer) {
    if ($packer
      ->applies($order, $shipping_profile)) {
      $proposed_shipments = $packer
        ->pack($order, $shipping_profile);
      if (!is_null($proposed_shipments)) {
        break;
      }
    }
  }
  return $proposed_shipments;
}