You are here

protected function USPSBase::setPackageType in Commerce USPS 8

Ensure a package type exists on the shipment.

Parameters

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

2 calls to USPSBase::setPackageType()
USPS::calculateRates in src/Plugin/Commerce/ShippingMethod/USPS.php
Calculates rates for the given shipment.
USPSInternational::calculateRates in src/Plugin/Commerce/ShippingMethod/USPSInternational.php
Calculates rates for the given shipment.

File

src/Plugin/Commerce/ShippingMethod/USPSBase.php, line 231

Class

USPSBase

Namespace

Drupal\commerce_usps\Plugin\Commerce\ShippingMethod

Code

protected function setPackageType(ShipmentInterface $shipment) {
  if (!$shipment
    ->getPackageType()) {
    $shipment
      ->setPackageType($this
      ->getDefaultPackageType());
  }
}