function uc_cart_remove_item in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_cart/uc_cart.module \uc_cart_remove_item()
- 7.3 uc_cart/uc_cart.module \uc_cart_remove_item()
Removes an item from the cart.
Parameters
$nid: The node ID of the item to remove.
$cid: The cart ID of the item to remove.
$data: The data array for the item to remove.
$op: The $op parameter to pass to hook_cart_item(), if not the default 'remove'.
5 calls to uc_cart_remove_item()
- hook_update_cart_item in docs/
hooks.php - Handles requests to update a cart item.
- UbercartCartCheckoutTestCase::testCartAPI in uc_cart/
uc_cart.test - uc_cart_empty in uc_cart/
uc_cart.module - Empties a cart of its contents.
- uc_product_kit_update_cart_item in uc_product_kit/
uc_product_kit.module - Implements hook_update_cart_item().
- uc_product_update_cart_item in uc_product/
uc_product.module - Implements hook_update_cart_item().
File
- uc_cart/
uc_cart.module, line 1602
Code
function uc_cart_remove_item($nid, $cid = NULL, $data = array(), $op = 'remove') {
if (empty($nid)) {
return;
}
$cart_id = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();
// Invoke hook_cart_item() with $op = 'remove' in enabled modules.
$result = db_query("SELECT c.*, n.title, n.vid FROM {node} n INNER JOIN {uc_cart_products} c ON n.nid = c.nid WHERE c.cart_id = '%s' AND c.nid = %d AND c.data = '%s'", $cart_id, $nid, serialize($data));
if ($item = db_fetch_object($result)) {
foreach (module_list() as $module) {
$func = $module . '_cart_item';
if (function_exists($func)) {
// $item must be passed by reference.
$func($op, $item);
}
}
}
db_query("DELETE FROM {uc_cart_products} WHERE cart_id = '%s' AND nid = %d AND data = '%s'", $cart_id, $nid, serialize($data));
}