|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jayS-de <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Cart; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
|
9
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
|
10
|
|
|
use Commercetools\Core\Model\Common\LocaleTrait; |
|
11
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
|
12
|
|
|
use Commercetools\Core\Model\Common\Address; |
|
13
|
|
|
use Commercetools\Core\Model\ShippingMethod\ShippingMethodReference; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @package Commercetools\Core\Model\Cart |
|
17
|
|
|
* @link https://dev.commercetools.com/http-api-projects-carts.html#cartdraft |
|
18
|
|
|
* @method string getCurrency() |
|
19
|
|
|
* @method string getCustomerId() |
|
20
|
|
|
* @method string getCountry() |
|
21
|
|
|
* @method string getInventoryMode() |
|
22
|
|
|
* @method CartDraft setCurrency(string $currency = null) |
|
23
|
|
|
* @method CartDraft setCustomerId(string $customerId = null) |
|
24
|
|
|
* @method CartDraft setCountry(string $country = null) |
|
25
|
|
|
* @method CartDraft setInventoryMode(string $inventoryMode = null) |
|
26
|
|
|
* @method CustomFieldObjectDraft getCustom() |
|
27
|
|
|
* @method CartDraft setCustom(CustomFieldObjectDraft $custom = null) |
|
28
|
|
|
* @method string getCustomerEmail() |
|
29
|
|
|
* @method CartDraft setCustomerEmail(string $customerEmail = null) |
|
30
|
|
|
* @method LineItemDraftCollection getLineItems() |
|
31
|
|
|
* @method CartDraft setLineItems(LineItemDraftCollection $lineItems = null) |
|
32
|
|
|
* @method Address getShippingAddress() |
|
33
|
|
|
* @method CartDraft setShippingAddress(Address $shippingAddress = null) |
|
34
|
|
|
* @method Address getBillingAddress() |
|
35
|
|
|
* @method CartDraft setBillingAddress(Address $billingAddress = null) |
|
36
|
|
|
* @method ShippingMethodReference getShippingMethod() |
|
37
|
|
|
* @method CartDraft setShippingMethod(ShippingMethodReference $shippingMethod = null) |
|
38
|
|
|
* @method CustomLineItemDraftCollection getCustomLineItems() |
|
39
|
|
|
* @method CartDraft setCustomLineItems(CustomLineItemDraftCollection $customLineItems = null) |
|
40
|
|
|
* @method string getTaxMode() |
|
41
|
|
|
* @method CartDraft setTaxMode(string $taxMode = null) |
|
42
|
|
|
* @method string getAnonymousId() |
|
43
|
|
|
* @method CartDraft setAnonymousId(string $anonymousId = null) |
|
44
|
|
|
* @method string getLocale() |
|
45
|
|
|
*/ |
|
46
|
|
|
class CartDraft extends JsonObject |
|
47
|
|
|
{ |
|
48
|
|
|
use LocaleTrait; |
|
49
|
|
|
|
|
50
|
94 |
|
public function fieldDefinitions() |
|
51
|
|
|
{ |
|
52
|
|
|
return [ |
|
53
|
94 |
|
'currency' => [static::TYPE => 'string'], |
|
54
|
94 |
|
'customerId' => [static::TYPE => 'string'], |
|
55
|
94 |
|
'customerEmail' => [static::TYPE => 'string'], |
|
56
|
94 |
|
'country' => [static::TYPE => 'string'], |
|
57
|
94 |
|
'inventoryMode' => [static::TYPE => 'string'], |
|
58
|
94 |
|
'lineItems' => [static::TYPE => '\Commercetools\Core\Model\Cart\LineItemDraftCollection'], |
|
59
|
94 |
|
'customLineItems' => [static::TYPE => '\Commercetools\Core\Model\Cart\CustomLineItemDraftCollection'], |
|
60
|
94 |
|
'shippingAddress' => [static::TYPE => '\Commercetools\Core\Model\Common\Address'], |
|
61
|
94 |
|
'billingAddress' => [static::TYPE => '\Commercetools\Core\Model\Common\Address'], |
|
62
|
94 |
|
'shippingMethod' => [static::TYPE => '\Commercetools\Core\Model\ShippingMethod\ShippingMethodReference'], |
|
63
|
94 |
|
'custom' => [static::TYPE => '\Commercetools\Core\Model\CustomField\CustomFieldObjectDraft'], |
|
64
|
94 |
|
'taxMode' => [static::TYPE => 'string'], |
|
65
|
94 |
|
'anonymousId' => [static::TYPE => 'string'], |
|
66
|
94 |
|
'locale' => [static::TYPE => 'string'], |
|
67
|
|
|
]; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param string $currency |
|
72
|
|
|
* @param Context|callable $context |
|
73
|
|
|
* @return CartDraft |
|
74
|
|
|
*/ |
|
75
|
94 |
|
public static function ofCurrency($currency, $context = null) |
|
76
|
|
|
{ |
|
77
|
94 |
|
$draft = static::of($context); |
|
78
|
94 |
|
return $draft->setCurrency($currency); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|