You are here

protected function FedEx::getRequestedPackageLineItemsCalculate in Commerce FedEx 8

Gets package line items for PACKAGE_CALCULATE strategy.

Parameters

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

Return value

array The package line items.

1 call to FedEx::getRequestedPackageLineItemsCalculate()
FedEx::getRequestedPackageLineItems in src/Plugin/Commerce/ShippingMethod/FedEx.php
Gets the requested package line items.

File

src/Plugin/Commerce/ShippingMethod/FedEx.php, line 732

Class

FedEx
Provides the FedEx shipping method.

Namespace

Drupal\commerce_fedex\Plugin\Commerce\ShippingMethod

Code

protected function getRequestedPackageLineItemsCalculate(ShipmentInterface $shipment) {
  $requested_package_line_items = $this
    ->getRequestedPackageLineItemsAllInOne($shipment);
  $packages = $this
    ->splitPackages($shipment);
  foreach ($requested_package_line_items as &$requested_package_line_item) {

    /** @var \NicholasCreativeMedia\FedExPHP\Structs\RequestedPackageLineItem $requested_package_line_item */
    $count = static::calculatePackageCount($requested_package_line_item, $packages[$requested_package_line_item
      ->getSequenceNumber() - 1]);
    if ($count) {
      $requested_package_line_item
        ->setGroupPackageCount($count);
      $requested_package_line_item
        ->getWeight()
        ->setValue($requested_package_line_item
        ->getWeight()
        ->getValue() / $count);
    }
  }
  return $requested_package_line_items;
}