You are here

function uc_cart_get_id in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_get_id()
  2. 7.3 uc_cart/uc_cart.module \uc_cart_get_id()

Returns the unique cart_id of the user.

Parameters

$create: Toggle auto creation of cart id.

Return value

Cart id. If $create is FALSE will return FALSE if there is no cart id.

12 calls to uc_cart_get_id()
hook_update_cart_item in docs/hooks.php
Handles requests to update a cart item.
UbercartCartCheckoutTestCase::testCartAPI in uc_cart/uc_cart.test
uc_2checkout_form in payment/uc_2checkout/uc_2checkout.module
Form to build the submission to 2Checkout.com.
uc_cart_add_item in uc_cart/uc_cart.module
Adds an item to a user's cart.
uc_cart_complete_sale in uc_cart/uc_cart.module
Completes a sale, including adjusting order status and creating user account.

... See full list

File

uc_cart/uc_cart.module, line 1342

Code

function uc_cart_get_id($create = TRUE) {
  global $user;
  if ($user->uid) {
    return $user->uid;
  }
  elseif (!isset($_SESSION['uc_cart_id']) && $create) {
    $_SESSION['uc_cart_id'] = md5(uniqid(rand(), TRUE));
  }
  return isset($_SESSION['uc_cart_id']) ? $_SESSION['uc_cart_id'] : FALSE;
}