You are here

public static function Package::loadByOrder in Ubercart 8.4

Loads packages for a given order.

Parameters

int $order_id: An order ID.

Return value

\Drupal\uc_fulfillment\Package[] Array of Package objects for the given order.

5 calls to Package::loadByOrder()
NewShipmentForm::buildForm in shipping/uc_fulfillment/src/Form/NewShipmentForm.php
Form constructor.
PackageController::listOrderPackages in shipping/uc_fulfillment/src/Controller/PackageController.php
Displays a list of an order's packaged products.
ShipmentController::listOrderShipments in shipping/uc_fulfillment/src/Controller/ShipmentController.php
Displays a list of shipments for an order.
uc_fulfillment_uc_order_actions in shipping/uc_fulfillment/uc_fulfillment.module
Implements hook_uc_order_actions().
uc_fulfillment_uc_order_delete in shipping/uc_fulfillment/uc_fulfillment.module
Implements hook_uc_order_delete().

File

shipping/uc_fulfillment/src/Package.php, line 461

Class

Package
Defines the Package class.

Namespace

Drupal\uc_fulfillment

Code

public static function loadByOrder($order_id) {
  $packages = [];
  $result = \Drupal::database()
    ->query('SELECT package_id FROM {uc_packages} WHERE order_id = :id ORDER BY package_id', [
    ':id' => $order_id,
  ]);
  while ($package_id = $result
    ->fetchField()) {
    $packages[] = Package::load($package_id);
  }
  return $packages;
}