|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\CartDiscount; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @package Commercetools\Core\Model\CartDiscount |
|
10
|
|
|
* |
|
11
|
|
|
* @method string getType() |
|
12
|
|
|
* @method MultiBuyCustomLineItemsTarget setType(string $type = null) |
|
13
|
|
|
* @method string getPredicate() |
|
14
|
|
|
* @method MultiBuyCustomLineItemsTarget setPredicate(string $predicate = null) |
|
15
|
|
|
* @method int getTriggerQuantity() |
|
16
|
|
|
* @method MultiBuyCustomLineItemsTarget setTriggerQuantity(int $triggerQuantity = null) |
|
17
|
|
|
* @method int getDiscountedQuantity() |
|
18
|
|
|
* @method MultiBuyCustomLineItemsTarget setDiscountedQuantity(int $discountedQuantity = null) |
|
19
|
|
|
* @method int getMaxOccurrence() |
|
20
|
|
|
* @method MultiBuyCustomLineItemsTarget setMaxOccurrence(int $maxOccurrence = null) |
|
21
|
|
|
* @method string getSelectionMode() |
|
22
|
|
|
* @method MultiBuyCustomLineItemsTarget setSelectionMode(string $selectionMode = null) |
|
23
|
|
|
*/ |
|
24
|
|
|
class MultiBuyCustomLineItemsTarget extends CartDiscountTarget |
|
25
|
|
|
{ |
|
26
|
|
|
const TARGET_TYPE = 'multiBuyCustomLineItems'; |
|
27
|
|
|
const MODE_CHEAPEST = 'Cheapest'; |
|
28
|
|
|
const MODE_MOST_EXPENSIVE = 'MostExpensive'; |
|
29
|
|
|
|
|
30
|
2 |
|
public function fieldDefinitions() |
|
31
|
|
|
{ |
|
32
|
|
|
return [ |
|
33
|
2 |
|
'type' => [static::TYPE => 'string'], |
|
34
|
2 |
|
'predicate' => [static::TYPE => 'string'], |
|
35
|
2 |
|
'triggerQuantity' => [static::TYPE => 'int'], |
|
36
|
2 |
|
'discountedQuantity' => [static::TYPE => 'int'], |
|
37
|
2 |
|
'maxOccurrence' => [static::TYPE => 'int'], |
|
38
|
2 |
|
'selectionMode' => [static::TYPE => 'string'], |
|
39
|
|
|
]; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public static function ofPredicateTriggerDiscountedAndMode( |
|
43
|
|
|
$predicate, |
|
44
|
|
|
$triggerQuantity, |
|
45
|
|
|
$discountedQuantity, |
|
46
|
|
|
$selectionMode, |
|
47
|
|
|
$context = null |
|
48
|
|
|
) { |
|
49
|
1 |
|
return static::of($context) |
|
50
|
1 |
|
->setPredicate($predicate) |
|
51
|
1 |
|
->setTriggerQuantity($triggerQuantity) |
|
52
|
1 |
|
->setDiscountedQuantity($discountedQuantity) |
|
53
|
1 |
|
->setSelectionMode($selectionMode); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|