You are here

public function CartProvider::getCart in Commerce Core 8.2

Gets the cart order for the given store and user.

Parameters

string $order_type: The order type ID.

\Drupal\commerce_store\Entity\StoreInterface $store: The store. If omitted, the current store is assumed.

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

Return value

\Drupal\commerce_order\Entity\OrderInterface|null The cart order, or NULL if none found.

Overrides CartProviderInterface::getCart

File

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

Class

CartProvider
Default implementation of the cart provider.

Namespace

Drupal\commerce_cart

Code

public function getCart($order_type, StoreInterface $store = NULL, AccountInterface $account = NULL) {
  $cart = NULL;
  $cart_id = $this
    ->getCartId($order_type, $store, $account);
  if ($cart_id) {
    $cart = $this->orderStorage
      ->load($cart_id);
  }
  return $cart;
}