public function test_get_conditions_by_type()
 {
     $cartCondition1 = new CartCondition(array('name' => 'SALE 5%', 'type' => 'sale', 'target' => 'subtotal', 'value' => '-5%'));
     $cartCondition2 = new CartCondition(array('name' => 'Item Gift Pack 25.00', 'type' => 'promo', 'target' => 'subtotal', 'value' => '-25'));
     $cartCondition3 = new CartCondition(array('name' => 'Item Less 8%', 'type' => 'promo', 'target' => 'subtotal', 'value' => '-8%'));
     $item = array('id' => 456, 'name' => 'Sample Item 1', 'price' => 100, 'quantity' => 1, 'attributes' => array());
     $this->cart->add($item);
     $this->cart->condition([$cartCondition1, $cartCondition2, $cartCondition3]);
     // now lets get all conditions added in the cart with the type "promo"
     $promoConditions = $this->cart->getConditionsByType('promo');
     $this->assertEquals(2, $promoConditions->count(), "We should have 2 items as promo condition type.");
 }
Exemple #2
0
 /**
  * Get all the condition filtered by Type
  * Please Note that this will only return condition added on cart bases, not those conditions added
  * specifically on an per item bases
  *
  * @param $type
  * @return \Darryldecode\Cart\CartConditionCollection 
  * @static 
  */
 public static function getConditionsByType($type)
 {
     return \Darryldecode\Cart\Cart::getConditionsByType($type);
 }