You are here

public function UPS::calculateRates in Commerce UPS 8.3

Calculates rates for the given shipment.

Parameters

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

Return value

\Drupal\commerce_shipping\ShippingRate[] The rates.

Overrides ShippingMethodInterface::calculateRates

File

src/Plugin/Commerce/ShippingMethod/UPS.php, line 264

Class

UPS
Provides the UPS shipping method.

Namespace

Drupal\commerce_ups\Plugin\Commerce\ShippingMethod

Code

public function calculateRates(ShipmentInterface $shipment) {

  // Only attempt to collect rates if an address exists on the shipment.
  if ($shipment
    ->getShippingProfile()
    ->get('address')
    ->isEmpty()) {
    return [];
  }
  return $this->upsRateService
    ->getRates($shipment, $this->parentEntity);
}