Is there a global variable of sorts that can be used as a bool to determine if something is in the basket?
2 Answers
This is what i use :)
function items_on_cart(){
global $user;
$cart = commerce_cart_order_load($user->uid);
$line_items = count($cart->commerce_line_items) ? true : false;
return $line_items;
}
Commerce Cart has the following function commerce_cart_order_session_exists()
which you could probably use to set a boolean value.
Checks to see if any order ID or a specific order ID exists in the session.
To answer your question directly though, there is no global variable to detect carts.
-
Thanks Chapabu, another good answer, just Marius pipped you to the post. May 15, 2012 at 15:04