You are here

public function CartTokenSession::addCartId in Commerce Cart API 8

Adds the given cart order ID to the session.

Parameters

int $cart_id: The cart order ID.

string $type: The cart session type.

Overrides CartSessionInterface::addCartId

File

src/CartTokenSession.php, line 69

Class

CartTokenSession
Decorates the cart session to support cart tokens.

Namespace

Drupal\commerce_cart_api

Code

public function addCartId($cart_id, $type = self::ACTIVE) {
  $this->inner
    ->addCartId($cart_id, $type);
  if ($this
    ->getCurrentRequestCartToken() !== NULL) {
    $data = $this
      ->getTokenCartData();
    $ids = $data[$type];
    $ids[] = $cart_id;
    $data[$type] = $ids;
    $this
      ->setTokenCartData($data);
  }
}