public function test_add_item_condition()
 {
     $itemCondition2 = new CartCondition(array('name' => 'Item Gift Pack 25.00', 'type' => 'promo', 'target' => 'item', 'value' => '-25'));
     $coupon101 = new CartCondition(array('name' => 'COUPON 101', 'type' => 'coupon', 'target' => 'item', 'value' => '-5%'));
     $item = array('id' => 456, 'name' => 'Sample Item 1', 'price' => 100, 'quantity' => 1, 'attributes' => array(), 'conditions' => [$itemCondition2]);
     $this->cart->add($item);
     // let's prove first we have 1 condition on this item
     $this->assertCount(1, $this->cart->get($item['id'])['conditions'], "Item should have 1 condition");
     // now let's insert a condition on an existing item on the cart
     $this->cart->addItemCondition($item['id'], $coupon101);
     $this->assertCount(2, $this->cart->get($item['id'])['conditions'], "Item should have 2 conditions");
 }
Exemple #2
0
 /**
  * add condition on an existing item on the cart
  *
  * @param int|string $productId
  * @param \Darryldecode\Cart\CartCondition $itemCondition
  * @return $this 
  * @static 
  */
 public static function addItemCondition($productId, $itemCondition)
 {
     return \Darryldecode\Cart\Cart::addItemCondition($productId, $itemCondition);
 }