1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Cart; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Channel\ChannelReference; |
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
11
|
|
|
use Commercetools\Core\Model\Common\LocalizedString; |
12
|
|
|
use Commercetools\Core\Model\Common\Money; |
13
|
|
|
use Commercetools\Core\Model\Common\Price; |
14
|
|
|
use Commercetools\Core\Model\Order\ItemState; |
15
|
|
|
use Commercetools\Core\Model\Order\ItemStateCollection; |
16
|
|
|
use Commercetools\Core\Model\Product\ProductVariant; |
17
|
|
|
use Commercetools\Core\Model\TaxCategory\TaxRate; |
18
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
19
|
|
|
use Commercetools\Core\Model\TaxCategory\ExternalTaxRateDraft; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @package Commercetools\Core\Model\Cart |
23
|
|
|
* @link https://docs.commercetools.com/http-api-projects-me-carts.html#mylineitemdraft |
24
|
|
|
* @method string getProductId() |
25
|
|
|
* @method MyLineItemDraft setProductId(string $productId = null) |
26
|
|
|
* @method int getVariantId() |
27
|
|
|
* @method MyLineItemDraft setVariantId(int $variantId = null) |
28
|
|
|
* @method int getQuantity() |
29
|
|
|
* @method MyLineItemDraft setQuantity(int $quantity = null) |
30
|
|
|
* @method ChannelReference getSupplyChannel() |
31
|
|
|
* @method MyLineItemDraft setSupplyChannel(ChannelReference $supplyChannel = null) |
32
|
|
|
* @method ChannelReference getDistributionChannel() |
33
|
|
|
* @method MyLineItemDraft setDistributionChannel(ChannelReference $distributionChannel = null) |
34
|
|
|
* @method CustomFieldObject getCustom() |
35
|
|
|
* @method MyLineItemDraft setCustom(CustomFieldObject $custom = null) |
36
|
|
|
* @method ItemShippingDetailsDraft getShippingDetails() |
37
|
|
|
* @method MyLineItemDraft setShippingDetails(ItemShippingDetailsDraft $shippingDetails = null) |
38
|
|
|
* @method string getSku() |
39
|
|
|
* @method MyLineItemDraft setSku(string $sku = null) |
40
|
|
|
*/ |
41
|
|
|
class MyLineItemDraft extends JsonObject |
42
|
|
|
{ |
43
|
6 |
|
public function fieldDefinitions() |
44
|
|
|
{ |
45
|
|
|
return [ |
46
|
6 |
|
'productId' => [static::TYPE => 'string'], |
47
|
6 |
|
'variantId' => [static::TYPE => 'int'], |
48
|
6 |
|
'quantity' => [static::TYPE => 'int'], |
49
|
6 |
|
'supplyChannel' => [static::TYPE => ChannelReference::class], |
50
|
6 |
|
'distributionChannel' => [static::TYPE => ChannelReference::class], |
51
|
6 |
|
'custom' => [static::TYPE => CustomFieldObject::class], |
52
|
6 |
|
'shippingDetails' => [static::TYPE => ItemShippingDetailsDraft::class], |
53
|
6 |
|
'sku' => [static::TYPE => 'string'], |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $productId |
59
|
|
|
* @param Context|callable $context |
60
|
|
|
* @return MyLineItemDraft |
61
|
|
|
*/ |
62
|
|
|
public static function ofProductId($productId, $context = null) |
63
|
|
|
{ |
64
|
|
|
return static::of($context)->setProductId($productId); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param string $sku |
69
|
|
|
* @param Context|callable $context |
70
|
|
|
* @return MyLineItemDraft |
71
|
|
|
*/ |
72
|
|
|
public static function ofSku($sku, $context = null) |
73
|
|
|
{ |
74
|
|
|
return static::of($context)->setSku($sku); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $productId |
79
|
|
|
* @param int $variantId |
80
|
|
|
* @param int $quantity |
81
|
|
|
* @param Context|callable $context |
82
|
|
|
* @return MyLineItemDraft |
83
|
|
|
*/ |
84
|
|
|
public static function ofProductIdVariantIdAndQuantity($productId, $variantId, $quantity, $context = null) |
85
|
|
|
{ |
86
|
|
|
return static::of($context)->setProductId($productId)->setVariantId($variantId)->setQuantity($quantity); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|