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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<?php
namespace Commercetools\Core\Model\CartDiscount;
use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Model\Common\JsonObject;
use Commercetools\Core\Model\Common\LocalizedString;
use Commercetools\Core\Model\Common\DateTimeDecorator;
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft;
use DateTime;
class CartDiscountDraft extends JsonObject
{
const NAME = 'name';
const DESCRIPTION = 'description';
const VALUE = 'value';
const CART_PREDICATE = 'cartPredicate';
const TARGET = 'target';
const SORT_ORDER = 'sortOrder';
const IS_ACTIVE = 'isActive';
const VALID_FROM = 'validFrom';
const VALID_UNTIL = 'validUntil';
const REQUIRES_DISCOUNT_CODE = 'requiresDiscountCode';
const STACKING_MODE = 'stackingMode';
const CUSTOM = 'custom';
const KEY = 'key';
public function fieldDefinitions()
{
return [
static::NAME => [static::TYPE => LocalizedString::class],
static::DESCRIPTION => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
static::VALUE => [static::TYPE => CartDiscountValue::class],
static::CART_PREDICATE => [static::TYPE => 'string'],
static::TARGET => [static::TYPE => CartDiscountTarget::class, static::OPTIONAL => true],
static::SORT_ORDER => [static::TYPE => 'string'],
static::IS_ACTIVE => [static::TYPE => 'bool', static::OPTIONAL => true],
static::VALID_FROM => [
static::TYPE => DateTime::class,
static::OPTIONAL => true,
static::DECORATOR => DateTimeDecorator::class
],
static::VALID_UNTIL => [
static::TYPE => DateTime::class,
static::OPTIONAL => true,
static::DECORATOR => DateTimeDecorator::class
],
static::REQUIRES_DISCOUNT_CODE => [static::TYPE => 'bool', static::OPTIONAL => true],
static::STACKING_MODE => [static::TYPE => 'string', static::OPTIONAL => true],
static::CUSTOM => [static::TYPE => CustomFieldObjectDraft::class, static::OPTIONAL => true],
static::KEY => [static::TYPE => 'string', static::OPTIONAL => true],
];
}
public static function ofNameValuePredicateTargetOrderActiveAndDiscountCode(
LocalizedString $name,
CartDiscountValue $value,
$cartPredicate,
CartDiscountTarget $target,
$sortOrder,
$isActive,
$requiresDiscountCode,
$context = null
) {
$draft = static::of($context);
return $draft->setName($name)
->setValue($value)
->setCartPredicate($cartPredicate)
->setTarget($target)
->setSortOrder($sortOrder)
->setIsActive($isActive)
->setRequiresDiscountCode($requiresDiscountCode);
}
public static function ofNameValuePredicateOrderActiveAndDiscountCode(
LocalizedString $name,
CartDiscountValue $value,
$cartPredicate,
$sortOrder,
$isActive,
$requiresDiscountCode,
$context = null
) {
$draft = static::of($context);
return $draft->setName($name)
->setValue($value)
->setCartPredicate($cartPredicate)
->setSortOrder($sortOrder)
->setIsActive($isActive)
->setRequiresDiscountCode($requiresDiscountCode);
}
}