commerce_cart_order_load
| DC commerce_cart.module | commerce_cart_order_load($uid = 0) |
Loads the shopping cart order for the specified user.
Parameters
$uid: The uid of the customer whose cart to load. If left 0, attempts to load an anonymous order from the session.
Return value
The fully loaded shopping cart order or FALSE if non-existent.
File
- sites/
all/ modules/ commerce/ modules/ cart/ commerce_cart.module, line 556 - Implements the shopping cart system and add to cart features.
Code
<?php
function commerce_cart_order_load($uid = 0) {
// Cart order IDs will be cached keyed by $uid.
$cart_order_ids = &drupal_static(__FUNCTION__);
// Cache the user's cart order ID if it hasn't been set already.
if (!isset($cart_order_ids[$uid])) {
$cart_order_ids[$uid] = commerce_cart_order_id($uid);
}
// If a valid cart order ID exists for the user, return it now.
if (!empty($cart_order_ids[$uid])) {
return commerce_order_load($cart_order_ids[$uid]);
}
return FALSE;
}
?> 