You are here

public static function CartItem::postLoad in Ubercart 8.4

Acts on loaded entities.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.

Overrides EntityBase::postLoad

File

uc_cart/src/Entity/CartItem.php, line 102

Class

CartItem
Defines the cart item entity class.

Namespace

Drupal\uc_cart\Entity

Code

public static function postLoad(EntityStorageInterface $storage, array &$items) {
  foreach ($items as $item) {
    $item->product = uc_product_load_variant($item->nid->target_id, $item->data
      ->first()
      ->toArray());
    if ($item->product) {
      $item->title = $item->product
        ->label();
      $item->model = $item->product->model;
      $item->cost = $item->product->cost->value;
      $item->price = $item->product->price;
      $item->weight = $item->product->weight->value;
      $item->weight_units = $item->product->weight->units;
    }
    $item->module = $item->data->module;
  }
  parent::postLoad($storage, $items);
}