public function UPSShipment::setWeight in Commerce UPS 8.3
Define the package weight.
Parameters
\Ups\Entity\Package $ups_package: A package object from the Ups API.
1 call to UPSShipment::setWeight()
- UPSShipment::setPackage in src/UPSShipment.php 
- Sets the package for a given shipment.
File
- src/UPSShipment.php, line 170 
Class
- UPSShipment
- Class to create and return a UPS API shipment object.
Namespace
Drupal\commerce_upsCode
public function setWeight(UPSPackage $ups_package) {
  $weight = $this->shipment
    ->getWeight()
    ->convert($this
    ->getValidWeightUnit());
  $ups_package_weight = new PackageWeight();
  $ups_package_weight
    ->setWeight($weight
    ->getNumber());
  $ups_package_weight
    ->setUnitOfMeasurement($this
    ->setUnitOfMeasurement($this
    ->getUnitOfMeasure($weight
    ->getUnit())));
  $ups_package
    ->setPackageWeight($ups_package_weight);
}