You are here

function uc_product_update_cart_item in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_product/uc_product.module \uc_product_update_cart_item()

Update information about a specific item in current cart.

1 call to uc_product_update_cart_item()
uc_product_kit_update_cart_item in uc_product_kit/uc_product_kit.module
Implementation of Übercart's hook_update_cart_item().

File

uc_product/uc_product.module, line 1493
The product module for Ubercart.

Code

function uc_product_update_cart_item($nid, $data = array(), $qty, $cid = NULL) {
  if (!$nid) {
    return NULL;
  }
  $cid = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();
  if ($qty < 1) {
    uc_cart_remove_item($nid, $cid, $data);
  }
  else {
    db_query("UPDATE {uc_cart_products} SET qty = %d, changed = %d WHERE nid = %d AND cart_id = '%s' AND data = '%s'", $qty, time(), $nid, $cid, serialize($data));
    cache_clear_all();
  }

  // Rebuild the items hash
  uc_cart_get_contents(NULL, 'rebuild');
}