You are here

function uc_wishlist_get_product in UC Wish List 6

Same name and namespace in other branches
  1. 7 uc_wishlist.module \uc_wishlist_get_product()
1 call to uc_wishlist_get_product()
uc_wishlist_order in ./uc_wishlist.module
Implements Ubercart hook_order.

File

./uc_wishlist.module, line 561
Allows users to create public shopping/wish lists.

Code

function uc_wishlist_get_product($wpid) {
  if (!$wpid) {
    return FALSE;
  }
  $item = FALSE;
  $res = db_query("SELECT w.*, n.title, n.vid FROM {node} n INNER JOIN {uc_wishlist_products} w ON n.nid = w.nid WHERE w.wpid = %d", $wpid);
  if ($item = db_fetch_object($res)) {
    $product = node_load($item->nid);
    $item->model = $product->model;
    $item->cost = $product->cost;
    $item->price = $product->sell_price;
    $item->weight = $product->weight;
    $item->weight_units = $product->weight_units;
    $item->shippable = $product->shippable;
    $item->data = unserialize($item->data);
    $item->module = $item->data['module'];
    $item->purchase = unserialize($item->purchase);
    $item->options = array();

    // add wishlist id data
    $item->data['wid'] = $item->wid;
    $item->data['wpid'] = $item->wpid;

    // Invoke hook_cart_item() with $op = 'modify' in enabled modules.
    // An especially important hook is uc_attribute_cart_item which
    // updates the item given the attributes.
    foreach (module_implements('cart_item') as $module) {
      if ($module == 'uc_wishlist') {
        continue;
      }
      $func = $module . '_cart_item';
      $func('load', $item);
    }
  }
  return $item;
}