Tracking.php in Ubercart 8.4
File
shipping/uc_fulfillment/src/Plugin/Ubercart/OrderPane/Tracking.php
View source
<?php
namespace Drupal\uc_fulfillment\Plugin\Ubercart\OrderPane;
use Drupal\uc_order\OrderPanePluginBase;
use Drupal\uc_fulfillment\Shipment;
use Drupal\uc_order\OrderInterface;
class Tracking extends OrderPanePluginBase {
public function getClasses() {
return [
'pos-left',
];
}
public function view(OrderInterface $uc_order, $view_mode) {
if ($view_mode == 'customer' || $view_mode == 'view') {
$tracking = [];
$shipments = Shipment::loadByOrder($uc_order
->id());
foreach ($shipments as $shipment) {
if ($shipment
->getTrackingNumber()) {
$tracking[$shipment
->getCarrier()][] = $shipment
->getTrackingNumber();
}
else {
foreach ($shipment
->getPackages() as $package) {
if ($package
->getTrackingNumber()) {
$tracking[$shipment
->getCarrier()][] = $package
->getTrackingNumber();
}
}
}
}
if ($view_mode == 'view' || !empty($tracking)) {
$build = [];
foreach ($tracking as $title => $list) {
$build[$title] = [
'#theme' => 'item_list',
'#title' => $title,
'#items' => $list,
];
}
if (empty($tracking)) {
$build = [
'#markup' => $this
->t('No tracking numbers have been entered.'),
];
}
return $build;
}
}
}
}
Classes
Name |
Description |
Tracking |
Display tracking numbers of shipped packages. |