0

Is there a global variable of sorts that can be used as a bool to determine if something is in the basket?

2 Answers 2

1

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;
}
0
0

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.

1
  • Thanks Chapabu, another good answer, just Marius pipped you to the post. Commented May 15, 2012 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.