You are here

public function CommerceCartProviderSession::cartExists in Commerce Core 7

Checks to see if any cart order ID or a specific cart order ID exists.

Parameters

$order_id: Optionally specify an order ID to look for; defaults to NULL.

$completed: Boolean indicating whether or not the operation should look in the completed orders array instead of the active cart orders array.

Return value

Boolean indicating whether or not a cart order ID exists for the given parameters.

Overrides CommerceCartProviderInterface::cartExists

File

modules/cart/plugins/cart_provider/CommerceCartProviderSession.class.php, line 30

Class

CommerceCartProviderSession
Defines a session array based cart provider.

Code

public function cartExists($order_id = NULL, $completed = FALSE) {
  $key = $completed ? self::COMPLETED : self::CART;

  // If an order was specified, look for it in the array.
  if (!empty($order_id)) {
    return !empty($_SESSION[$key]) && in_array($order_id, $_SESSION[$key]);
  }
  else {

    // Otherwise look for any value.
    return !empty($_SESSION[$key]);
  }
}