You are here

function commerce_cart_get_properties in Commerce Core 7

Entity metadata callback: returns the current user's shopping cart order.

See also

commerce_cart_entity_property_info_alter()

1 string reference to 'commerce_cart_get_properties'
commerce_cart_entity_property_info_alter in modules/cart/commerce_cart.info.inc
Implements hook_entity_property_info_alter().

File

modules/cart/commerce_cart.module, line 1202
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_get_properties($data = FALSE, array $options, $name) {
  global $user;
  switch ($name) {
    case 'current_cart_order':
      if ($order = commerce_cart_order_load($user->uid)) {
        return $order;
      }
      else {
        return commerce_order_new($user->uid, 'cart');
      }
  }
}