|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jayS-de <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\CartDiscount; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
9
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
|
10
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
|
11
|
|
|
use Commercetools\Core\Model\Common\DateTimeDecorator; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @package Commercetools\Core\Model\CartDiscount |
|
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-cartDiscounts.html#cart-discount |
|
16
|
|
|
* @method LocalizedString getName() |
|
17
|
|
|
* @method CartDiscountDraft setName(LocalizedString $name = null) |
|
18
|
|
|
* @method LocalizedString getDescription() |
|
19
|
|
|
* @method CartDiscountDraft setDescription(LocalizedString $description = null) |
|
20
|
|
|
* @method CartDiscountValue getValue() |
|
21
|
|
|
* @method CartDiscountDraft setValue(CartDiscountValue $value = null) |
|
22
|
|
|
* @method string getCartPredicate() |
|
23
|
|
|
* @method CartDiscountDraft setCartPredicate(string $cartPredicate = null) |
|
24
|
|
|
* @method CartDiscountTarget getTarget() |
|
25
|
|
|
* @method CartDiscountDraft setTarget(CartDiscountTarget $target = null) |
|
26
|
|
|
* @method string getSortOrder() |
|
27
|
|
|
* @method CartDiscountDraft setSortOrder(string $sortOrder = null) |
|
28
|
|
|
* @method bool getIsActive() |
|
29
|
|
|
* @method CartDiscountDraft setIsActive(bool $isActive = null) |
|
30
|
|
|
* @method DateTimeDecorator getValidFrom() |
|
31
|
|
|
* @method CartDiscountDraft setValidFrom(\DateTime $validFrom = null) |
|
32
|
|
|
* @method DateTimeDecorator getValidUntil() |
|
33
|
|
|
* @method CartDiscountDraft setValidUntil(\DateTime $validUntil = null) |
|
34
|
|
|
* @method bool getRequiresDiscountCode() |
|
35
|
|
|
* @method CartDiscountDraft setRequiresDiscountCode(bool $requiresDiscountCode = null) |
|
36
|
|
|
*/ |
|
37
|
|
|
class CartDiscountDraft extends JsonObject |
|
38
|
|
|
{ |
|
39
|
|
|
const NAME = 'name'; |
|
40
|
|
|
const DESCRIPTION = 'description'; |
|
41
|
|
|
const VALUE = 'value'; |
|
42
|
|
|
const CART_PREDICATE = 'cartPredicate'; |
|
43
|
|
|
const TARGET = 'target'; |
|
44
|
|
|
const SORT_ORDER = 'sortOrder'; |
|
45
|
|
|
const IS_ACTIVE = 'isActive'; |
|
46
|
|
|
const VALID_FROM = 'validFrom'; |
|
47
|
|
|
const VALID_UNTIL = 'validUntil'; |
|
48
|
|
|
const REQUIRES_DISCOUNT_CODE = 'requiresDiscountCode'; |
|
49
|
|
|
|
|
50
|
5 |
|
public function fieldDefinitions() |
|
51
|
|
|
{ |
|
52
|
|
|
return [ |
|
53
|
5 |
|
static::NAME => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], |
|
54
|
5 |
|
static::DESCRIPTION => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'], |
|
55
|
5 |
|
static::VALUE => [static::TYPE => '\Commercetools\Core\Model\CartDiscount\CartDiscountValue'], |
|
56
|
5 |
|
static::CART_PREDICATE => [static::TYPE => 'string'], |
|
57
|
5 |
|
static::TARGET => [static::TYPE => '\Commercetools\Core\Model\CartDiscount\CartDiscountTarget'], |
|
58
|
5 |
|
static::SORT_ORDER => [static::TYPE => 'string'], |
|
59
|
5 |
|
static::IS_ACTIVE => [static::TYPE => 'bool'], |
|
60
|
5 |
|
static::VALID_FROM => [ |
|
61
|
5 |
|
static::TYPE => '\DateTime', |
|
62
|
5 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' |
|
63
|
5 |
|
], |
|
64
|
5 |
|
static::VALID_UNTIL => [ |
|
65
|
5 |
|
static::TYPE => '\DateTime', |
|
66
|
5 |
|
static::DECORATOR => '\Commercetools\Core\Model\Common\DateTimeDecorator' |
|
67
|
5 |
|
], |
|
68
|
5 |
|
static::REQUIRES_DISCOUNT_CODE => [static::TYPE => 'bool'], |
|
69
|
5 |
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param LocalizedString $name |
|
74
|
|
|
* @param CartDiscountValue $value |
|
75
|
|
|
* @param string $cartPredicate |
|
76
|
|
|
* @param CartDiscountTarget $target |
|
77
|
|
|
* @param string $sortOrder |
|
78
|
|
|
* @param bool $isActive |
|
79
|
|
|
* @param bool $requiresDiscountCode |
|
80
|
|
|
* @param Context|callable $context |
|
81
|
|
|
* @return CartDiscountDraft |
|
82
|
|
|
*/ |
|
83
|
5 |
|
public static function ofNameValuePredicateTargetOrderActiveAndDiscountCode( |
|
84
|
|
|
LocalizedString $name, |
|
85
|
|
|
CartDiscountValue $value, |
|
86
|
|
|
$cartPredicate, |
|
87
|
|
|
CartDiscountTarget $target, |
|
88
|
|
|
$sortOrder, |
|
89
|
|
|
$isActive, |
|
90
|
|
|
$requiresDiscountCode, |
|
91
|
|
|
$context = null |
|
92
|
|
|
) { |
|
93
|
5 |
|
$draft = static::of($context); |
|
94
|
5 |
|
return $draft->setName($name) |
|
95
|
5 |
|
->setValue($value) |
|
96
|
5 |
|
->setCartPredicate($cartPredicate) |
|
97
|
5 |
|
->setTarget($target) |
|
98
|
5 |
|
->setSortOrder($sortOrder) |
|
99
|
5 |
|
->setIsActive($isActive) |
|
100
|
5 |
|
->setRequiresDiscountCode($requiresDiscountCode); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|