function testRemoveItemFromCart()
 {
     /* Add 2 different products to the cart */
     $this->get('product-2a/add');
     $this->get('product-2b/add');
     $this->get('product-2b/add');
     $item1ID = $this->idFromFixture('Product', 'p2a');
     $item2ID = $this->idFromFixture('Product', 'p2b');
     /* See what's in the cart in session */
     $items = ShoppingCart::get_items();
     /* There are 2 items in the cart. 1 of the first item, 2 of the second item */
     $this->assertEquals(count($items), 2, 'There are 2 items in the cart');
     $this->assertEquals($items[0]->getIDAttribute(), $item1ID, 'The first item is the same ID as the first product.');
     $this->assertEquals($items[0]->getQuantity(), 1, 'There is 1 of the first item.');
     $this->assertEquals($items[1]->getIDAttribute(), $item2ID, 'The second item is the same ID as the second product.');
     $this->assertEquals($items[1]->getQuantity(), 2, 'There are 2 of the second item.');
     /* Let's remove 1 piece of the second item from the cart */
     ShoppingCart::remove_item($item2ID, 1);
     /* We now have 1 piece left of the second item in the cart */
     $items = ShoppingCart::get_items();
     $this->assertEquals($items[1]->getQuantity(), 1, 'We now have 1 piece of the second item in the cart, we removed 1.');
     /* Now, let's remove the final piece of the item, removing that item from the cart completely */
     ShoppingCart::remove_item($item2ID, 1);
     /* Take a peek in the cart once again to see what changed */
     $items = ShoppingCart::get_items();
     /* We have none of the second item in the cart, because we removed both 2 pieces of it that existed */
     $this->assertTrue(empty($items[1]), 'There is no index of 1 because the item doesn\'t exist in the cart any longer.');
     /* Clear the shopping cart */
     ShoppingCart::clear();
 }
 function removeitem()
 {
     $itemId = $this->urlParams['ID'];
     if ($itemId) {
         ShoppingCart::remove_item($itemId);
         if (!$this->isAjax()) {
             Director::redirectBack();
         }
     }
 }
 function removeitem($request)
 {
     if ($item = ShoppingCart::get_item($this->urlFilter())) {
         ShoppingCart::remove_item($item);
         return self::return_data("success", "Item removed");
         //TODO: i18n
     }
     return self::return_data("failure", "Item could not be found in cart");
     //TODO: i18n
 }