You are here

interface PackerInterface in Commerce Shipping 8.2

Creates one or more shipments for a given order.

Allows sites to automatically split an order into multiple shipments based on stock location, weight, dimensions, or some other criteria.

Important: A single order item can be added to multiple shipments only if all shipments are going to share the same shipping profile. This limitation is imposed by commerce_tax and TaxSubscriber which need to select a shipping profile for each order item.

Hierarchy

Expanded class hierarchy of PackerInterface

All classes that implement PackerInterface

4 files declare their use of PackerInterface
PackerManager.php in src/PackerManager.php
PackerManagerInterface.php in src/PackerManagerInterface.php
PackerManagerTest.php in tests/src/Kernel/PackerManagerTest.php
TestPacker.php in tests/modules/commerce_shipping_test/src/Packer/TestPacker.php

File

src/Packer/PackerInterface.php, line 20

Namespace

Drupal\commerce_shipping\Packer
View source
interface PackerInterface {

  /**
   * Determines whether the packer applies to the given order.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The order.
   * @param \Drupal\profile\Entity\ProfileInterface $shipping_profile
   *   The shipping profile.
   *
   * @return bool
   *   TRUE if the packer applies to the given order, FALSE otherwise.
   */
  public function applies(OrderInterface $order, ProfileInterface $shipping_profile);

  /**
   * Packs the given order.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The order.
   * @param \Drupal\profile\Entity\ProfileInterface $shipping_profile
   *   The shipping profile.
   *
   * @return \Drupal\commerce_shipping\ProposedShipment[]
   *   The proposed shipments.
   */
  public function pack(OrderInterface $order, ProfileInterface $shipping_profile);

}

Members

Namesort descending Modifiers Type Description Overrides
PackerInterface::applies public function Determines whether the packer applies to the given order. 2
PackerInterface::pack public function Packs the given order. 2