Function to determine whether my Cart is empty? I want to set an access callback on a menu item (primary links) for the shopping cart so that it only displays when there is something in the cart.  However, I can't find an obvious function to to this, and I don't know where to start with my own code.

Any suggestion is appreciated.
Using the same technique as commerce_cart_block_view (thanks to Ryan Szrama for the assist!), you'll need to:


Get the order using commerce_cart_order_load, then check to see if there are no line items.
Apply the entity metadata wrapper to retrieve further wrappers for the entity properties
Count line items in the cart, filtering for products only


For the access callback itself, take a look at Do you have an example of hook_menu() access callback? for several examples and links to documentation.

Therefore, the callback should be something like:

function MODULE_access_check() {
  global $user;
  if ($order = commerce_cart_order_load($user-&gt;uid)) {
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    return commerce_line_items_quantity($wrapper-&gt;commerce_line_items, commerce_product_line_item_types()) &gt; 0;
  }
  return FALSE;
}