public function Cart::getContents in Ubercart 8.4
Returns the items in the shopping cart.
Return value
\Drupal\uc_cart\CartItemInterface[] The items.
Overrides CartInterface::getContents
1 call to Cart::getContents()
- Cart::isShippable in uc_cart/
src/ Cart.php - Determines whether a cart contains shippable items or not.
File
- uc_cart/
src/ Cart.php, line 47
Class
- Cart
- Utility class providing methods for the management of shopping carts.
Namespace
Drupal\uc_cartCode
public function getContents() {
$items = [];
$result = \Drupal::entityQuery('uc_cart_item')
->condition('cart_id', $this->id)
->sort('cart_item_id', 'ASC')
->execute();
if (!empty($result)) {
$items = \Drupal::entityTypeManager()
->getStorage('uc_cart_item')
->loadMultiple(array_keys($result));
}
// Allow other modules a chance to alter the fully loaded cart object.
\Drupal::moduleHandler()
->alter('uc_cart', $items);
return $items;
}