Get cart items and check for product of type X
Well this seems to work!

global $user;
$order = commerce_cart_order_load($user-&gt;uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);

foreach ($wrapper-&gt;commerce_line_items as $delta =&gt; $line_item_wrapper) {                                  
  $type = $line_item_wrapper-&gt;commerce_product-&gt;value()-&gt;type;   
  if($type=='X'){
    //perform a task
  }
}