1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// lets create first our condition instance
$saleCondition = new \Darryldecode\Cart\CartCondition(array(
'name' => 'SALE 5%',
'type' => 'tax',
'value' => '-5%',
));
// now the product to be added on cart
$product = array(
'id' => 456,
'name' => 'Sample Item 1',
'price' => 100,
'quantity' => 1,
'attributes' => array(),
'conditions' => $saleCondition
);
// finally add the product on the cart
Cart::add($product);
// you may also add multiple condition on an item
$itemCondition1 = new \Darryldecode\Cart\CartCondition(array(
'name' => 'SALE 5%',
'type' => 'sale',
'value' => '-5%',
));
$itemCondition2 = new CartCondition(array(
'name' => 'Item Gift Pack 25.00',
'type' => 'promo',
'value' => '-25',
));
$itemCondition3 = new \Darryldecode\Cart\CartCondition(array(
'name' => 'MISC',
'type' => 'misc',
'value' => '+10',
));
$item = array(
'id' => 456,
'name' => 'Sample Item 1',
'price' => 100,
'quantity' => 1,
'attributes' => array(),
'conditions' => [$itemCondition1, $itemCondition2, $itemCondition3]
);
Cart::add($item); |
Partager