You are here

protected function CartManager::getId in Ubercart 8.4

1 call to CartManager::getId()
CartManager::get in uc_cart/src/CartManager.php
Loads a cart object.

File

uc_cart/src/CartManager.php, line 62

Class

CartManager
Provides the cart manager service.

Namespace

Drupal\uc_cart

Code

protected function getId($create = TRUE) {
  if ($this->currentUser
    ->isAuthenticated()) {
    return $this->currentUser
      ->id();
  }
  elseif (!$this->session
    ->has('uc_cart_id') && $create) {
    $this->session
      ->set('uc_cart_id', md5(uniqid(rand(), TRUE)));
  }
  return $this->session
    ->has('uc_cart_id') ? $this->session
    ->get('uc_cart_id') : FALSE;
}