You are here

public function Test::getTrackingUrl in Commerce Shipping 8.2

Gets the tracking url for the given shipment.

Parameters

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

Return value

\Drupal\core\Url|null The tracking URL, or NULL if not available yet.

Overrides SupportsTrackingInterface::getTrackingUrl

File

tests/modules/commerce_shipping_test/src/Plugin/Commerce/ShippingMethod/Test.php, line 25

Class

Test
Provides the Test shipping method.

Namespace

Drupal\commerce_shipping_test\Plugin\Commerce\ShippingMethod

Code

public function getTrackingUrl(ShipmentInterface $shipment) {
  $tracking_code = $shipment
    ->getTrackingCode();
  if (!empty($tracking_code)) {
    return Url::fromUri('https://www.drupal.org/' . $tracking_code);
  }
}