public function test_clear_cart_conditions()
 {
     // NOTE:
     // This only clears all conditions that has been added in a cart bases
     // this does not remove conditions on per item bases
     $itemCondition1 = new CartCondition(array('name' => 'SALE 5%', 'type' => 'sale', 'target' => 'subtotal', 'value' => '-5%'));
     $itemCondition2 = new CartCondition(array('name' => 'Item Gift Pack 25.00', 'type' => 'promo', 'target' => 'subtotal', 'value' => '-25'));
     $item = array('id' => 456, 'name' => 'Sample Item 1', 'price' => 100, 'quantity' => 1, 'attributes' => array());
     $this->cart->add($item);
     $this->cart->condition([$itemCondition1, $itemCondition2]);
     // let's prove first we have now two conditions in the cart
     $this->assertEquals(2, $this->cart->getConditions()->count(), 'Cart should have two conditions');
     // now let's clear cart conditions
     $this->cart->clearCartConditions();
     // cart should have now only 1 condition
     $this->assertEquals(0, $this->cart->getConditions()->count(), 'Cart should have no conditions now');
 }
Example #2
0
 /**
  * clears all conditions on a cart,
  * this does not remove conditions that has been added specifically to an item/product.
  * 
  * If you wish to remove a specific condition to a product, you may use the method: removeItemCondition($itemId, $conditionName)
  *
  * @return void 
  * @static 
  */
 public static function clearCartConditions()
 {
     \Darryldecode\Cart\Cart::clearCartConditions();
 }