Check contents of order in commerce So I have a custom module function that checks a cart order for a certain product type

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'){
    //go mental
  }
}  


This is used within checkout to display certain list items for "checkout progress" depending on whether a product type is in the cart (i.e show the gift aid stage if there is a donation).

The issue with this is it seems that when the order is no longer within the cart, for example when we hit the payment stage, and further go on to checkout complete. So the function commerce_cart_order_load($user-&gt;uid); no longer works. How would I achieve this same functionality checking the order for product of type 'X' when the order status is updated post-shopping-cart?

I think I can use $order = commerce_order_load(); but somehow I need to get the $order_id?
$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.