You are here

public function CartProvider::getCartIds in Commerce Core 8.2

Gets all cart order ids 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

int[] A list of cart orders ids.

Overrides CartProviderInterface::getCartIds

1 call to CartProvider::getCartIds()
CartProvider::getCarts in modules/cart/src/CartProvider.php
Gets all cart orders for the given user.

File

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

Class

CartProvider
Default implementation of the cart provider.

Namespace

Drupal\commerce_cart

Code

public function getCartIds(AccountInterface $account = NULL, StoreInterface $store = NULL) {

  // Filter out cart IDS that do not belong to the store passed.
  $cart_data = array_filter($this
    ->loadCartData($account), function ($data) use ($store) {
    return !$store || $store
      ->id() === $data['store_id'];
  });
  return array_keys($cart_data);
}