You are here

public function CartProvider::getCarts in Commerce Core 8.2

Gets all cart orders for the given user.

Parameters

\Drupal\Core\Session\AccountInterface|null $account: The user. If omitted, the current user is assumed.

\Drupal\commerce_store\Entity\StoreInterface|null $store: The store. If omitted, carts belonging to all stores are returned.

Return value

\Drupal\commerce_order\Entity\OrderInterface[] A list of cart orders.

Overrides CartProviderInterface::getCarts

File

modules/cart/src/CartProvider.php, line 165

Class

CartProvider
Default implementation of the cart provider.

Namespace

Drupal\commerce_cart

Code

public function getCarts(AccountInterface $account = NULL, StoreInterface $store = NULL) {
  $carts = [];
  $cart_ids = $this
    ->getCartIds($account, $store);
  if ($cart_ids) {
    $carts = $this->orderStorage
      ->loadMultiple($cart_ids);
  }
  return $carts;
}