Drupal 7: Programatically Loading commerece cart item of a user with samplecode

In Drupal commerce, cart items are handled as Entity. The cart items are referenced to the particular user id. Using user id we can able to load cart details that are currently added by the user. The function "commerce_cart_order_load()" takes user id as argument to load the cart details. The below example shows how to load cart details of the current user.


$cartDetails = commerce_cart_order_load(USER_ID);


global $user;
$cartDetails = commerce_cart_order_load(USER_ID);
print_r($cartDetails); // Print current user cart details.