commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MergeCartDraftBuilder.php
1<?php
2
3declare(strict_types=1);
10
16use stdClass;
17
21final class MergeCartDraftBuilder implements Builder
22{
27 private $anonymousCart;
28
33 private $mergeMode;
34
39 private $updateProductData;
40
45 private $anonymousId;
46
53 public function getAnonymousCart()
54 {
55 return $this->anonymousCart instanceof CartResourceIdentifierBuilder ? $this->anonymousCart->build() : $this->anonymousCart;
56 }
57
64 public function getMergeMode()
65 {
66 return $this->mergeMode;
67 }
68
75 public function getUpdateProductData()
76 {
77 return $this->updateProductData;
78 }
79
87 public function getAnonymousId()
88 {
89 return $this->anonymousId;
90 }
91
96 public function withAnonymousCart(?CartResourceIdentifier $anonymousCart)
97 {
98 $this->anonymousCart = $anonymousCart;
99
100 return $this;
101 }
102
107 public function withMergeMode(?string $mergeMode)
108 {
109 $this->mergeMode = $mergeMode;
110
111 return $this;
112 }
113
118 public function withUpdateProductData(?bool $updateProductData)
119 {
120 $this->updateProductData = $updateProductData;
121
122 return $this;
123 }
124
129 public function withAnonymousId(?string $anonymousId)
130 {
131 $this->anonymousId = $anonymousId;
132
133 return $this;
134 }
135
141 {
142 $this->anonymousCart = $anonymousCart;
143
144 return $this;
145 }
146
147 public function build(): MergeCartDraft
148 {
149 return new MergeCartDraftModel(
150 $this->anonymousCart instanceof CartResourceIdentifierBuilder ? $this->anonymousCart->build() : $this->anonymousCart,
151 $this->mergeMode,
152 $this->updateProductData,
153 $this->anonymousId
154 );
155 }
156
157 public static function of(): MergeCartDraftBuilder
158 {
159 return new self();
160 }
161}
withAnonymousCartBuilder(?CartResourceIdentifierBuilder $anonymousCart)
withAnonymousCart(?CartResourceIdentifier $anonymousCart)