You are here

function uc_cart_get_item in Ubercart 6.2

Allows us to get one single line item in a cart.

Parameters

$item: Either an item row from the database, or the cart item ID to fetch.

Return value

Fully loaded cart item or NULL if item not found

1 call to uc_cart_get_item()
uc_cart_get_contents in uc_cart/uc_cart.module
Grabs the items in a shopping cart for a user.

File

uc_cart/uc_cart.module, line 1446

Code

function uc_cart_get_item($item) {
  if (!is_object($item)) {
    $item = db_fetch_object(db_query("SELECT * FROM {uc_cart_products} WHERE cart_item_id = '%d'", $item));
  }
  if (empty($item)) {
    return;
  }
  $product = node_load($item->nid);
  if (!$product) {
    return;
  }
  $item->vid = $product->vid;
  $item->title = $product->title;
  $item->cost = $product->cost;
  $item->price = $product->sell_price;
  $item->weight = $product->weight;
  $item->data = unserialize($item->data);
  $item->module = $item->data['module'];
  $item->model = $product->model;

  // Invoke hook_cart_item() with $op = 'load' in enabled modules.
  foreach (module_list() as $module) {
    $func = $module . '_cart_item';
    if (function_exists($func)) {

      // $item must be passed by reference.
      $func('load', $item);
    }
  }
  return $item;
}