Composable Commerce PHP SDKPHP SDK
  • Namespace
  • Class
  • Tree

Namespaces

  • Commercetools
    • Commons
      • Helper
    • Core
      • Builder
        • Request
        • Update
      • Cache
      • Client
        • Adapter
        • OAuth
      • Error
      • Helper
        • Annotate
        • State
          • Renderer
        • Subscriber
          • Log
      • Model
        • ApiClient
        • Cart
        • CartDiscount
        • Category
        • Channel
        • Common
        • Customer
        • CustomerGroup
        • CustomField
        • CustomObject
        • DiscountCode
        • Extension
        • Inventory
        • Message
        • Order
        • OrderEdit
        • Payment
        • Product
          • Search
        • ProductDiscount
        • ProductSelection
        • ProductType
        • Project
        • Review
        • ShippingMethod
        • ShoppingList
        • State
        • Store
        • Subscription
        • TaxCategory
        • Type
        • Zone
      • Request
        • ApiClients
        • CartDiscounts
          • Command
        • Carts
          • Command
        • Categories
          • Command
        • Channels
          • Command
        • CustomerGroups
          • Command
        • Customers
          • Command
        • CustomField
          • Command
        • CustomObjects
        • DiscountCodes
          • Command
        • Extensions
          • Command
        • GraphQL
        • InStores
        • Inventory
          • Command
        • Me
          • Command
        • Messages
        • OrderEdits
          • Command
          • StagedOrder
            • Command
        • Orders
          • Command
        • Payments
          • Command
        • ProductDiscounts
          • Command
        • Products
          • Command
        • ProductSelections
          • Command
        • ProductTypes
          • Command
        • Project
          • Command
        • Query
        • Reviews
          • Command
        • ShippingMethods
          • Command
        • ShoppingLists
          • Command
        • States
          • Command
        • Stores
          • Command
        • Subscriptions
          • Command
        • TaxCategories
          • Command
        • Types
          • Command
        • Zones
          • Command
      • Response

Classes

  • AbsoluteCartDiscountValue
  • CartDiscount
  • CartDiscountCollection
  • CartDiscountDraft
  • CartDiscountReference
  • CartDiscountReferenceCollection
  • CartDiscountTarget
  • CartDiscountValue
  • CustomLineItemsTarget
  • GiftLineItemCartDiscountValue
  • LineItemsTarget
  • MultiBuyCustomLineItemsTarget
  • MultiBuyLineItemsTarget
  • RelativeCartDiscountValue
  • ShippingCostTarget
  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
/**
 * @author @jenschude <jens.schulze@commercetools.de>
 */

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;

/**
 * @package Commercetools\Core\Model\CartDiscount
 * @link https://docs.commercetools.com/http-api-projects-cartDiscounts.html#cartdiscount
 * @method LocalizedString getName()
 * @method CartDiscountDraft setName(LocalizedString $name = null)
 * @method LocalizedString getDescription()
 * @method CartDiscountDraft setDescription(LocalizedString $description = null)
 * @method CartDiscountValue getValue()
 * @method CartDiscountDraft setValue(CartDiscountValue $value = null)
 * @method string getCartPredicate()
 * @method CartDiscountDraft setCartPredicate(string $cartPredicate = null)
 * @method CartDiscountTarget getTarget()
 * @method CartDiscountDraft setTarget(CartDiscountTarget $target = null)
 * @method string getSortOrder()
 * @method CartDiscountDraft setSortOrder(string $sortOrder = null)
 * @method bool getIsActive()
 * @method CartDiscountDraft setIsActive(bool $isActive = null)
 * @method DateTimeDecorator getValidFrom()
 * @method CartDiscountDraft setValidFrom(DateTime $validFrom = null)
 * @method DateTimeDecorator getValidUntil()
 * @method CartDiscountDraft setValidUntil(DateTime $validUntil = null)
 * @method bool getRequiresDiscountCode()
 * @method CartDiscountDraft setRequiresDiscountCode(bool $requiresDiscountCode = null)
 * @method string getStackingMode()
 * @method CartDiscountDraft setStackingMode(string $stackingMode = null)
 * @method CustomFieldObjectDraft getCustom()
 * @method CartDiscountDraft setCustom(CustomFieldObjectDraft $custom = null)
 * @method string getKey()
 * @method CartDiscountDraft setKey(string $key = null)
 */
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],
        ];
    }

    /**
     * @param LocalizedString $name
     * @param CartDiscountValue $value
     * @param string $cartPredicate
     * @param CartDiscountTarget $target
     * @param string $sortOrder
     * @param bool $isActive
     * @param bool $requiresDiscountCode
     * @param Context|callable $context
     * @return CartDiscountDraft
     */
    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);
    }

    /**
     * @param LocalizedString $name
     * @param CartDiscountValue $value
     * @param string $cartPredicate
     * @param string $sortOrder
     * @param bool $isActive
     * @param bool $requiresDiscountCode
     * @param Context|callable $context
     * @return CartDiscountDraft
     */
    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);
    }
}
PHP SDK API documentation generated by ApiGen