function hook_uc_update_cart_item in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_cart/uc_cart.api.php \hook_uc_update_cart_item()
Handles requests to update a cart item.
Parameters
$nid: Node id of the cart item.
$data: Array of extra information about the item.
$qty: The quantity of this item in the cart.
$cid: The cart id. Defaults to NULL, which indicates that the current user's cart should be retrieved with uc_cart_get_id().
2 functions implement hook_uc_update_cart_item()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- uc_product_kit_uc_update_cart_item in uc_product_kit/
uc_product_kit.module - Implements hook_uc_update_cart_item().
- uc_product_uc_update_cart_item in uc_product/
uc_product.module - Implements hook_uc_update_cart_item().
2 invocations of hook_uc_update_cart_item()
- uc_cart_add_item in uc_cart/
uc_cart.module - Adds an item to a user's cart.
- uc_cart_update_item_object in uc_cart/
uc_cart.module - Updates the quantity of all the items in a cart object.
File
- uc_cart/
uc_cart.api.php, line 455 - Hooks provided by the Cart module.
Code
function hook_uc_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_update('uc_cart_products')
->fields(array(
'qty' => $qty,
'changed' => REQUEST_TIME,
))
->condition('nid', $nid)
->condition('cart_id', $cid)
->condition('data', serialize($data))
->execute();
}
// Rebuild the items hash
uc_cart_get_contents(NULL, 'rebuild');
if (!strpos(request_uri(), 'cart', -4)) {
drupal_set_message(t('Your item(s) have been updated.'));
}
}