Check contents of order in commerce
$order_id = arg(1);
$orderLoad = commerce_order_load($order_id);

foreach ($orderLoad-&gt;commerce_line_items['und'] as $line) {
    $line_item = commerce_line_item_load($line['line_item_id']);
    $product_id = $line_item-&gt;commerce_product['und'][0]['product_id']; 
    $product = commerce_product_load($product_id);
    $type = $product-&gt;type;

    if($type == 'X'){
      //go mental
    }
}


If anyone has any improvements to this code (to make it more efficient etc. then please comment below). Thanks.