You are here

protected function Shipping::getShipments in Commerce Shipping 8.2

Gets the order's shipments.

Filters out shipments which are still incomplete (no rate selected).

Parameters

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

Return value

\Drupal\commerce_shipping\Entity\ShipmentInterface[] The shipments.

3 calls to Shipping::getShipments()
Shipping::applyDefault in src/Plugin/Commerce/TaxType/Shipping.php
Applies the default tax rate of the order's tax type.
Shipping::applyHighest in src/Plugin/Commerce/TaxType/Shipping.php
Applies the highest tax rate found on the order.
Shipping::applyProportional in src/Plugin/Commerce/TaxType/Shipping.php
Applies each order item's tax rate proportionally.

File

src/Plugin/Commerce/TaxType/Shipping.php, line 391

Class

Shipping
Provides the Shipping tax type.

Namespace

Drupal\commerce_shipping\Plugin\Commerce\TaxType

Code

protected function getShipments(OrderInterface $order) {

  /** @var \Drupal\commerce_shipping\Entity\Shipment[] $shipments */
  $shipments = $order
    ->get('shipments')
    ->referencedEntities();
  $shipments = array_filter($shipments, function (ShipmentInterface $shipment) {
    return $shipment
      ->getShippingMethodId() && $shipment
      ->getAmount();
  });
  return $shipments;
}