Number of item in cart at theme level
You can use commerce_cart_order_load() to load the order for the current user, and an EntityMetadataWrapper to extract the relevant field data, and commerce_line_items_quantity() to get at the actual quantities. e.g.

if ($order = commerce_cart_order_load($GLOBALS['user']-&gt;uid)) {
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  $quantity = commerce_line_items_quantity($order_wrapper-&gt;commerce_line_items);

  // Do something with $quantity...
}


This code can be used in a module or theme.