public function test_clear_item_conditions() { $itemCondition1 = new CartCondition(array('name' => 'SALE 5%', 'type' => 'sale', 'target' => 'item', 'value' => '-5%')); $itemCondition2 = new CartCondition(array('name' => 'Item Gift Pack 25.00', 'type' => 'promo', 'target' => 'item', 'value' => '-25')); $item = array('id' => 456, 'name' => 'Sample Item 1', 'price' => 100, 'quantity' => 1, 'attributes' => array(), 'conditions' => [$itemCondition1, $itemCondition2]); $this->cart->add($item); // let's very first the item has 2 conditions in it $this->assertCount(2, $this->cart->get(456)['conditions'], 'Item should have two conditions'); // now let's remove all condition on that item $this->cart->clearItemConditions(456); // now we should have only 0 condition left on that item $this->assertCount(0, $this->cart->get(456)['conditions'], 'Item should have no conditions now'); }
/** * remove all conditions that has been applied on an item that is already on the cart * * @param $itemId * @return bool * @static */ public static function clearItemConditions($itemId) { return \Darryldecode\Cart\Cart::clearItemConditions($itemId); }