public function USPSShipmentBase::setDimensions in Commerce USPS 8
Sets the package dimensions.
2 calls to USPSShipmentBase::setDimensions()
- USPSShipment::buildPackage in src/
USPSShipment.php - Returns an initialized rate package object.
- USPSShipmentInternational::buildPackage in src/
USPSShipmentInternational.php - Returns an initialized rate package object.
File
- src/
USPSShipmentBase.php, line 106
Class
- USPSShipmentBase
- Class that sets the shipment details needed for the USPS request.
Namespace
Drupal\commerce_uspsCode
public function setDimensions() {
$package_type = $this
->getPackageType();
if (!empty($package_type)) {
$length = ceil($package_type
->getLength()
->convert('in')
->getNumber());
$width = ceil($package_type
->getWidth()
->convert('in')
->getNumber());
$height = ceil($package_type
->getHeight()
->convert('in')
->getNumber());
$size = $length > 12 || $width > 12 || $height > 12 ? 'LARGE' : 'REGULAR';
$this->uspsPackage
->setField('Size', $size);
$this->uspsPackage
->setField('Width', $width);
$this->uspsPackage
->setField('Length', $length);
$this->uspsPackage
->setField('Height', $height);
$this->uspsPackage
->setField('Girth', 0);
}
}