function uc_cart_empty in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_cart/uc_cart.module \uc_cart_empty()
- 6.2 uc_cart/uc_cart.module \uc_cart_empty()
Empties a cart of its contents.
Parameters
$cart_id: The ID of the cart, or NULL to empty the current cart.
7 calls to uc_cart_empty()
- UbercartCartCheckoutTestCase::testCartApi in uc_cart/
tests/ uc_cart.test - Tests cart API.
- uc_2checkout_complete in payment/
uc_2checkout/ uc_2checkout.pages.inc - Finalizes 2Checkout transaction.
- uc_cart_complete_sale in uc_cart/
uc_cart.module - Completes a sale, including adjusting order status and creating user account.
- uc_cart_cron in uc_cart/
uc_cart.module - Implements hook_cron().
- uc_cart_empty_confirm_submit in uc_cart/
uc_cart.pages.inc - Submission handler to empty the cart after confirmations.
File
- uc_cart/
uc_cart.module, line 1277
Code
function uc_cart_empty($cart_id = NULL) {
$cart_id = $cart_id ? $cart_id : uc_cart_get_id(FALSE);
if (!$cart_id) {
return;
}
$efq = new EntityFieldQuery();
$result = $efq
->entityCondition('entity_type', 'uc_cart_item')
->propertyCondition('cart_id', $cart_id)
->execute();
if (!empty($result['uc_cart_item'])) {
entity_delete_multiple('uc_cart_item', array_keys($result['uc_cart_item']));
}
// Remove cached cart.
uc_cart_get_contents($cart_id, 'empty');
}