function uc_cart_get_id in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_cart/uc_cart.module \uc_cart_get_id()
- 6.2 uc_cart/uc_cart.module \uc_cart_get_id()
Returns the unique cart_id of the user.
Parameters
bool $create: Toggle auto creation of cart id.
Return value
Cart id. If $create is FALSE will return FALSE if there is no cart id.
10 calls to uc_cart_get_id()
- hook_uc_update_cart_item in uc_cart/
uc_cart.api.php - Handles requests to update a cart item.
- 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_empty in uc_cart/
uc_cart.module - Empties a cart of its contents.
- uc_cart_get_contents in uc_cart/
uc_cart.module - Grabs the items in a shopping cart for a user.
File
- uc_cart/
uc_cart.module, line 994
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;
}