You are here

protected function FedEx::getRequestedPackageLineItemsAllInOne in Commerce FedEx 8

Gets package line items for PACKAGE_ALL_IN_ONE strategy.

Parameters

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

Return value

array The package line items.

2 calls to FedEx::getRequestedPackageLineItemsAllInOne()
FedEx::getRequestedPackageLineItems in src/Plugin/Commerce/ShippingMethod/FedEx.php
Gets the requested package line items.
FedEx::getRequestedPackageLineItemsCalculate in src/Plugin/Commerce/ShippingMethod/FedEx.php
Gets package line items for PACKAGE_CALCULATE strategy.

File

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

Class

FedEx
Provides the FedEx shipping method.

Namespace

Drupal\commerce_fedex\Plugin\Commerce\ShippingMethod

Code

protected function getRequestedPackageLineItemsAllInOne(ShipmentInterface $shipment) {
  $packages = $this
    ->splitPackages($shipment);
  $requested_package_line_items = [];
  foreach ($packages as $delta => $package) {
    $requested_package_line_item = new RequestedPackageLineItem();
    $shipment_title = $shipment
      ->getTitle();
    if (!is_string($shipment_title)) {
      $shipment_title = $shipment_title
        ->render();
    }
    $requested_package_line_item
      ->setSequenceNumber($delta + 1)
      ->setGroupPackageCount(1)
      ->setWeight(static::packageTotalWeight($package, $shipment
      ->getPackageType()))
      ->setDimensions($this
      ->packageToFedexDimensions($shipment
      ->getPackageType()))
      ->setPhysicalPackaging(PhysicalPackagingType::VALUE_BOX)
      ->setItemDescription($shipment_title);
    if ($this->configuration['options']['insurance']) {
      $requested_package_line_item
        ->setInsuredValue(new Money($shipment
        ->getTotalDeclaredValue()
        ->getCurrencyCode(), $shipment
        ->getTotalDeclaredValue()
        ->getNumber()));
    }
    $requested_package_line_items[] = $this
      ->adjustPackage($requested_package_line_item, $package, $shipment);
  }
  return $requested_package_line_items;
}