public static function FedEx::getFedexPackageVolume in Commerce FedEx 8
Determine the package volume from a fedex package dimensions item.
Parameters
\NicholasCreativeMedia\FedExPHP\Structs\Dimensions $dimensions: The fexed package dimensions item.
Return value
\Drupal\physical\Volume The total package volume.
Throws
\Exception
1 call to FedEx::getFedexPackageVolume()
- FedEx::calculatePackageCount in src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php - Determines a package count given package and item volumes.
File
- src/
Plugin/ Commerce/ ShippingMethod/ FedEx.php, line 1236
Class
- FedEx
- Provides the FedEx shipping method.
Namespace
Drupal\commerce_fedex\Plugin\Commerce\ShippingMethodCode
public static function getFedexPackageVolume(Dimensions $dimensions) {
$volume_value = $dimensions
->getHeight() * $dimensions
->getLength() * $dimensions
->getWidth();
switch ($dimensions
->getUnits()) {
case LinearUnits::VALUE_CM:
$volume_units = VolumeUnit::CUBIC_CENTIMETER;
break;
case LinearUnits::VALUE_IN:
$volume_units = VolumeUnit::CUBIC_INCH;
break;
default:
throw new \Exception("Invalid Dimensions");
}
return new Volume((string) $volume_value, $volume_units);
}