If Drupal Commerce Cart is not Empty, add a class to body I'd like to add a class to body if the current user's cart is not empty.

I'd like to take the preprocess approach and not using rules.

so far using commerce_cart_order_load function I came up with this in template.php:

function THEME_preprocess_html(&amp;$vars) {
    global $user;
    $order = commerce_cart_order_load($user-&gt;uid);

    if ($order != 0) {
        $vars['classes_array'][] = 'cart-loaded';
    }
}


but unfortunately it throws an unknown error.
Using this resource and thanks to @rémy I come up with this solution:

function THEME_preprocess_html(&amp;$vars) {
    global $user;
    $cart = commerce_cart_order_load($user-&gt;uid);
    foreach (entity_metadata_wrapper('commerce_order', $cart)-&gt;commerce_line_items as $delta =&gt; $line_item_wrapper) {
      if (in_array($line_item_wrapper-&gt;type-&gt;value(), commerce_product_line_item_types())) {
        $vars['classes_array'][] = 'cart-loaded';
      }
    }
}



  So after a while of testing I ended up with an error with anonymous
  users, so I digged a little bit deeper and come up with something new
  and no errors this time:


function THEMENAME_preprocess_html(&amp;$vars) {
    global $user;
    $quantity = 0;
    $order = commerce_cart_order_load($user-&gt;uid);
    if ($order) {
        $wrapper = entity_metadata_wrapper('commerce_order', $order);
        $line_items = $wrapper-&gt;commerce_line_items;
        $quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
        if ($quantity) {
            $vars['classes_array'][] = 'cart-loaded';
        }
    }
}