protected function FedEx::getRequestedPackageLineItemsIndividual in Commerce FedEx 8
Gets package line items for PACKAGE_INDIVIDUAL strategy.
Parameters
\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment.
Return value
array The package line items.
1 call to FedEx::getRequestedPackageLineItemsIndividual()
- FedEx::getRequestedPackageLineItems in src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php - Gets the requested package line items.
File
- src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php, line 756
Class
- FedEx
- Provides the FedEx shipping method.
Namespace
Drupal\commerce_fedex\Plugin\Commerce\ShippingMethodCode
protected function getRequestedPackageLineItemsIndividual(ShipmentInterface $shipment) {
$requested_package_line_items = [];
$weightUnits = '';
foreach ($shipment
->getItems() as $delta => $shipment_item) {
$requested_package_line_item = new RequestedPackageLineItem();
if ($weightUnits == '') {
/* All packages must have the same Weight Unit */
$weightUnits = $shipment_item
->getWeight()
->getUnit();
}
$requested_package_line_item
->setSequenceNumber($delta + 1)
->setGroupPackageCount(1)
->setWeight($this
->physicalWeightToFedex($shipment_item
->getWeight()
->convert($weightUnits)))
->setDimensions($this
->packageToFedexDimensions($shipment
->getPackageType()))
->setPhysicalPackaging(PhysicalPackagingType::VALUE_BOX)
->setItemDescription($this
->getCleanTitle($shipment_item));
if ($this->configuration['options']['insurance']) {
$requested_package_line_item
->setInsuredValue(new Money($shipment_item
->getDeclaredValue()
->getCurrencyCode(), $shipment_item
->getDeclaredValue()
->getNumber()));
}
$this
->adjustPackage($requested_package_line_item, [
$shipment_item,
], $shipment);
$requested_package_line_items[] = $requested_package_line_item;
}
return $requested_package_line_items;
}