public function CartTokenSession::hasCartId in Commerce Cart API 8
Checks whether the given cart order ID exists in the session.
Parameters
int $cart_id: The cart order ID.
string $type: The cart session type.
Return value
bool TRUE if the given cart order ID exists in the session, FALSE otherwise.
Overrides CartSessionInterface::hasCartId
File
- src/
CartTokenSession.php, line 84
Class
- CartTokenSession
- Decorates the cart session to support cart tokens.
Namespace
Drupal\commerce_cart_apiCode
public function hasCartId($cart_id, $type = self::ACTIVE) {
if ($this
->getCurrentRequestCartToken() === NULL) {
return $this->inner
->hasCartId($cart_id, $type);
}
$data = $this
->getTokenCartData();
$ids = $data[$type];
return in_array($cart_id, $ids, TRUE);
}