diff --git a/uc_cart/tests/uc_cart.test b/uc_cart/tests/uc_cart.test index d96f837..5ec03b0 100644 --- a/uc_cart/tests/uc_cart.test +++ b/uc_cart/tests/uc_cart.test @@ -103,8 +103,7 @@ class UbercartCartCheckoutTestCase extends UbercartTestHelper { // Empty the cart. uc_cart_add_item($this->product->nid); - // @TODO: default to the current cart - uc_cart_empty(uc_cart_get_id()); + uc_cart_empty(); $items = uc_cart_get_contents(); $this->assertEqual($items, array(), 'Cart is emptied correctly.'); diff --git a/uc_cart/uc_cart.module b/uc_cart/uc_cart.module index e98c7e2..91226d5 100644 --- a/uc_cart/uc_cart.module +++ b/uc_cart/uc_cart.module @@ -893,7 +893,7 @@ function uc_cart_complete_sale($order, $login = FALSE) { $output = filter_xss_admin(implode(' ', $messages)); // Empty that cart... - uc_cart_empty(uc_cart_get_id(FALSE)); + uc_cart_empty(); return array( '#theme' => 'uc_cart_complete_sale', @@ -1252,10 +1252,12 @@ function uc_cart_update_item_object($cart) { * Empties a cart of its contents. * * @param $cart_id - * The ID of the cart. + * The ID of the cart, or NULL to empty the current cart. */ -function uc_cart_empty($cart_id) { - if (is_null($cart_id) || empty($cart_id)) { +function uc_cart_empty($cart_id = NULL) { + $cart_id = $cart_id ? $cart_id : uc_cart_get_id(FALSE); + + if (!$cart_id) { return; } diff --git a/uc_cart_links/uc_cart_links.pages.inc b/uc_cart_links/uc_cart_links.pages.inc index 1e38cb7..2b511f8 100644 --- a/uc_cart_links/uc_cart_links.pages.inc +++ b/uc_cart_links/uc_cart_links.pages.inc @@ -156,7 +156,7 @@ function uc_cart_links_process($cart_actions) { case 'e': case 'E': if (variable_get('uc_cart_links_empty', TRUE)) { - uc_cart_empty(uc_cart_get_id()); + uc_cart_empty(); } break;