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

  • ProductDiscount
  • ProductDiscountCollection
  • ProductDiscountDraft
  • ProductDiscountReference
  • ProductDiscountValue
 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 
<?php
/**
 * @author @jenschude <jens.schulze@commercetools.de>
 */

namespace Commercetools\Core\Model\ProductDiscount;

use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Model\Common\DateTimeDecorator;
use Commercetools\Core\Model\Common\JsonObject;
use Commercetools\Core\Model\Common\LocalizedString;
use DateTime;

/**
 * @package Commercetools\Core\Model\ProductDiscount
 * @link https://docs.commercetools.com/http-api-projects-productDiscounts.html#productdiscountdraft
 * @method LocalizedString getName()
 * @method ProductDiscountDraft setName(LocalizedString $name = null)
 * @method LocalizedString getDescription()
 * @method ProductDiscountDraft setDescription(LocalizedString $description = null)
 * @method ProductDiscountValue getValue()
 * @method ProductDiscountDraft setValue(ProductDiscountValue $value = null)
 * @method string getPredicate()
 * @method ProductDiscountDraft setPredicate(string $predicate = null)
 * @method string getSortOrder()
 * @method ProductDiscountDraft setSortOrder(string $sortOrder = null)
 * @method bool getIsActive()
 * @method ProductDiscountDraft setIsActive(bool $isActive = null)
 * @method DateTimeDecorator getValidFrom()
 * @method ProductDiscountDraft setValidFrom(DateTime $validFrom = null)
 * @method DateTimeDecorator getValidUntil()
 * @method ProductDiscountDraft setValidUntil(DateTime $validUntil = null)
 * @method string getKey()
 * @method ProductDiscountDraft setKey(string $key = null)
 */
class ProductDiscountDraft extends JsonObject
{
    public function fieldDefinitions()
    {
        return [
            'name' => [static::TYPE => LocalizedString::class],
            'key' => [static::TYPE => 'string', static::OPTIONAL => true],
            'description' => [static::TYPE => LocalizedString::class, static::OPTIONAL => true],
            'value' => [static::TYPE => ProductDiscountValue::class],
            'predicate' => [static::TYPE => 'string'],
            'sortOrder' => [static::TYPE => 'string'],
            'isActive' => [static::TYPE => 'bool'],
            'validFrom' => [
                static::TYPE => DateTime::class,
                static::OPTIONAL => true,
                static::DECORATOR => DateTimeDecorator::class
            ],
            'validUntil' => [
                static::TYPE => DateTime::class,
                static::OPTIONAL => true,
                static::DECORATOR => DateTimeDecorator::class
            ],
        ];
    }

    /**
     * @param LocalizedString $name
     * @param ProductDiscountValue $value
     * @param string $predicate
     * @param string $sortOrder
     * @param bool $isActive
     * @param Context|callable $context
     * @return ProductDiscountDraft
     */
    public static function ofNameDiscountPredicateOrderAndActive(
        LocalizedString $name,
        ProductDiscountValue $value,
        $predicate,
        $sortOrder,
        $isActive,
        $context = null
    ) {
        return static::of($context)
            ->setName($name)
            ->setValue($value)
            ->setPredicate($predicate)
            ->setSortOrder($sortOrder)
            ->setIsActive($isActive);
    }
}
PHP SDK API documentation generated by ApiGen