You are here

function uc_cart_remove_item in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_remove_item()
  2. 6.2 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.

2 calls to uc_cart_remove_item()
hook_uc_update_cart_item in uc_cart/uc_cart.api.php
Handles requests to update a cart item.
UbercartCartCheckoutTestCase::testCartApi in uc_cart/tests/uc_cart.test
Tests cart API.

File

uc_cart/uc_cart.module, line 1238

Code

function uc_cart_remove_item($nid, $cid = NULL, $data = array()) {
  if (empty($nid)) {
    return;
  }
  $cart_id = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();
  $efq = new EntityFieldQuery();
  $result = $efq
    ->entityCondition('entity_type', 'uc_cart_item')
    ->propertyCondition('cart_id', $cart_id)
    ->propertyCondition('nid', $nid)
    ->propertyCondition('data', serialize($data))
    ->execute();
  if (!empty($result['uc_cart_item'])) {
    entity_delete_multiple('uc_cart_item', array_keys($result['uc_cart_item']));
  }
}