Drupal Commerce: Get order quantity from order_id with sample code

In Drupal, commerce order contains multiple products. These products are attached to the line item to the orders. The line item table holds the information about the quantities and other information. The below is the simplest code to get the quantity of the order with different products.

Sample Code: 

$order = commerce_order_load(ORDER_ID); // Load commerce order.
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$quantity_count = 0; // Initialize quantity.
foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
    // If line item is a commerce product type
    if (in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {
      // Get quantity from the Line items.
      $quantity_count += $line_item_wrapper->quantity->value();    
    }
  }
}
print "Total Qunantity is " . $quantity_count; 
Category: