Check if certain line item type exists
You can check for a certain type of line item on an order using one of the two following methods.

Given an order, let's look for a shipping line item.

// Load your order.
$order = commerce_order_load(/* Order ID */);


Without Metadata Wrappers

if (!empty($order-&gt;commerce_line_items)) {
  // Iterate over the line items.
  foreach ($order-&gt;commerce_line_items[LANGUAGE_NONE] as $line_item_data) {
    $line_item = commerce_line_item_load($line_item_data['line_item_id']);
    // Check the type.
    if ($line_item-&gt;type == 'shipping') {
      // Shipping line item found. Do the things.
    }
  }
}


With Wrappers

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Iteration is a bit simpler here.
foreach ($order_wrapper-&gt;commerce_line_items as $line_item) {
  // We have to access it using -&gt;value().
  if ($line_item-&gt;type-&gt;value() == 'shipping') {
    // Shipping line item found. Do the things.
  }
}