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.

▾ 12 functions call commerce_cart_order_load()

CommerceBaseTestCase::createDummyOrder in sites/all/modules/commerce/tests/commerce_base.test
Create a dummy order in a given status.
CommerceCartTestCaseMultiProducts::testCommerceCartOrder in sites/all/modules/commerce/modules/cart/tests/commerce_cart.test
Test if the product is present in the order stored in db.
CommerceCartTestCaseSimpleProduct::testCommerceCartOrder in sites/all/modules/commerce/modules/cart/tests/commerce_cart.test
Test if the product is present in the order stored in db.
commerce_cart_block_view in sites/all/modules/commerce/modules/cart/commerce_cart.module
Implements hook_block_view().
commerce_cart_checkout_router in sites/all/modules/commerce/modules/cart/includes/commerce_cart.pages.inc
Redirects invalid checkout attempts or displays the checkout form if valid.
commerce_cart_get_properties in sites/all/modules/commerce/modules/cart/commerce_cart.module
Entity metadata callback: returns the current user's shopping cart order.
commerce_cart_menu_item_title in sites/all/modules/commerce/modules/cart/commerce_cart.module
Returns the title of the shopping cart menu item with an item count.
commerce_cart_product_add in sites/all/modules/commerce/modules/cart/commerce_cart.module
Adds the specified product to a customer's shopping cart.
commerce_cart_user_login in sites/all/modules/commerce/modules/cart/commerce_cart.module
Implements hook_user_login().
commerce_cart_view in sites/all/modules/commerce/modules/cart/includes/commerce_cart.pages.inc
Displays the shopping cart form and associated information.
commerce_stock_check_cart_product_level in sites/all/modules/commerce_stock/commerce_stock.module
check if product is in the cart and return the quentity if it is
order_example_create_order_with_product in sites/all/modules/commerce_examples/order_example/order_example.module
Creates an order (or adds to an existing cart) and line item with the provided with the product id and UID

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;
}
?>