Views: Display Total number of products in commerce kickstart shopping cart I'm using menu badges to display the total number of products in the commerce kickstart shopping cart. However I cannot simple use aggregation to count the total number or products using line item ID because I need to multiply it by the quantity, and add it to the total.
Since the shopping cart already displays the total number of items, I though it would have been easy to do some reverse engineering but I couldn't find it.
In menu badges module check line no 335 code

/**
 * Drupal Commcerce cart items count callback.
 * @param array $arguments
 */
function menu_badges_commerce_cart_item_count() {
  global $user;

  if (module_exists('commerce_cart') &amp;&amp; $order = commerce_cart_order_load($user-&gt;uid)) {
    // Count the number of product line items on the order.
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    $quantity = commerce_line_items_quantity($wrapper-&gt;commerce_line_items, commerce_product_line_item_types());
    if ($quantity &gt; 0) {
      return $quantity;
    }
  }
  return NULL;
}


You can get total quantity using below code also...

  global $user;
  $order = commerce_cart_order_load($user-&gt;uid);
  $wrapper = entity_metadata_wrapper('commerce_order', $order);
  $quantity_total = 0;
  foreach ($wrapper-&gt;commerce_line_items as $delta =&gt; $line_item_wrapper) {
    $quantity = $line_item_wrapper-&gt;quantity-&gt;value();
    $quantity_total = $quantity_total + $quantity;
  }


Commerce modules does not provide view handler for Quantity Total.. If you are interested you can create one and share it with community.. Other wise you can use views php module to achieve same...