commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CartBuilder.php
1<?php
2
3declare(strict_types=1);
10
38use DateTimeImmutable;
39use stdClass;
40
44final class CartBuilder implements Builder
45{
50 private $id;
51
56 private $version;
57
62 private $createdAt;
63
68 private $lastModifiedAt;
69
74 private $key;
75
80 private $customerId;
81
86 private $customerEmail;
87
92 private $customerGroup;
93
98 private $anonymousId;
99
104 private $businessUnit;
105
110 private $store;
111
116 private $lineItems;
117
122 private $customLineItems;
123
128 private $totalLineItemQuantity;
129
134 private $totalPrice;
135
140 private $taxedPrice;
141
146 private $taxedShippingPrice;
147
152 private $discountOnTotalPrice;
153
158 private $taxMode;
159
164 private $taxRoundingMode;
165
170 private $taxCalculationMode;
171
176 private $inventoryMode;
177
182 private $cartState;
183
188 private $billingAddress;
189
194 private $shippingAddress;
195
200 private $shippingMode;
201
206 private $shippingKey;
207
212 private $shippingInfo;
213
218 private $shippingRateInput;
219
224 private $shippingCustomFields;
225
230 private $shipping;
231
236 private $itemShippingAddresses;
237
242 private $discountCodes;
243
248 private $directDiscounts;
249
254 private $refusedGifts;
255
260 private $paymentInfo;
261
266 private $country;
267
272 private $locale;
273
278 private $origin;
279
284 private $custom;
285
290 private $deleteDaysAfterLastModification;
291
296 private $lastModifiedBy;
297
302 private $createdBy;
303
310 public function getId()
311 {
312 return $this->id;
313 }
314
321 public function getVersion()
322 {
323 return $this->version;
324 }
325
332 public function getCreatedAt()
333 {
334 return $this->createdAt;
335 }
336
343 public function getLastModifiedAt()
344 {
345 return $this->lastModifiedAt;
346 }
347
354 public function getKey()
355 {
356 return $this->key;
357 }
358
365 public function getCustomerId()
366 {
367 return $this->customerId;
368 }
369
376 public function getCustomerEmail()
377 {
378 return $this->customerEmail;
379 }
380
387 public function getCustomerGroup()
388 {
389 return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup;
390 }
391
398 public function getAnonymousId()
399 {
400 return $this->anonymousId;
401 }
402
409 public function getBusinessUnit()
410 {
411 return $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit;
412 }
413
420 public function getStore()
421 {
422 return $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store;
423 }
424
431 public function getLineItems()
432 {
433 return $this->lineItems;
434 }
435
442 public function getCustomLineItems()
443 {
444 return $this->customLineItems;
445 }
446
453 public function getTotalLineItemQuantity()
454 {
455 return $this->totalLineItemQuantity;
456 }
457
466 public function getTotalPrice()
467 {
468 return $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice;
469 }
470
481 public function getTaxedPrice()
482 {
483 return $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice;
484 }
485
492 public function getTaxedShippingPrice()
493 {
494 return $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice;
495 }
496
503 public function getDiscountOnTotalPrice()
504 {
505 return $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice;
506 }
507
514 public function getTaxMode()
515 {
516 return $this->taxMode;
517 }
518
525 public function getTaxRoundingMode()
526 {
527 return $this->taxRoundingMode;
528 }
529
536 public function getTaxCalculationMode()
537 {
538 return $this->taxCalculationMode;
539 }
540
547 public function getInventoryMode()
548 {
549 return $this->inventoryMode;
550 }
551
558 public function getCartState()
559 {
560 return $this->cartState;
561 }
562
569 public function getBillingAddress()
570 {
571 return $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress;
572 }
573
580 public function getShippingAddress()
581 {
582 return $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress;
583 }
584
591 public function getShippingMode()
592 {
593 return $this->shippingMode;
594 }
595
602 public function getShippingKey()
603 {
604 return $this->shippingKey;
605 }
606
613 public function getShippingInfo()
614 {
615 return $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo;
616 }
617
630 public function getShippingRateInput()
631 {
632 return $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput;
633 }
634
641 public function getShippingCustomFields()
642 {
643 return $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields;
644 }
645
652 public function getShipping()
653 {
654 return $this->shipping;
655 }
656
664 public function getItemShippingAddresses()
665 {
666 return $this->itemShippingAddresses;
667 }
668
675 public function getDiscountCodes()
676 {
677 return $this->discountCodes;
678 }
679
686 public function getDirectDiscounts()
687 {
688 return $this->directDiscounts;
689 }
690
697 public function getRefusedGifts()
698 {
699 return $this->refusedGifts;
700 }
701
708 public function getPaymentInfo()
709 {
710 return $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo;
711 }
712
719 public function getCountry()
720 {
721 return $this->country;
722 }
723
730 public function getLocale()
731 {
732 return $this->locale;
733 }
734
741 public function getOrigin()
742 {
743 return $this->origin;
744 }
745
752 public function getCustom()
753 {
754 return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
755 }
756
764 {
765 return $this->deleteDaysAfterLastModification;
766 }
767
774 public function getLastModifiedBy()
775 {
776 return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
777 }
778
785 public function getCreatedBy()
786 {
787 return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
788 }
789
794 public function withId(?string $id)
795 {
796 $this->id = $id;
797
798 return $this;
799 }
800
805 public function withVersion(?int $version)
806 {
807 $this->version = $version;
808
809 return $this;
810 }
811
816 public function withCreatedAt(?DateTimeImmutable $createdAt)
817 {
818 $this->createdAt = $createdAt;
819
820 return $this;
821 }
822
827 public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
828 {
829 $this->lastModifiedAt = $lastModifiedAt;
830
831 return $this;
832 }
833
838 public function withKey(?string $key)
839 {
840 $this->key = $key;
841
842 return $this;
843 }
844
849 public function withCustomerId(?string $customerId)
850 {
851 $this->customerId = $customerId;
852
853 return $this;
854 }
855
860 public function withCustomerEmail(?string $customerEmail)
861 {
862 $this->customerEmail = $customerEmail;
863
864 return $this;
865 }
866
871 public function withCustomerGroup(?CustomerGroupReference $customerGroup)
872 {
873 $this->customerGroup = $customerGroup;
874
875 return $this;
876 }
877
882 public function withAnonymousId(?string $anonymousId)
883 {
884 $this->anonymousId = $anonymousId;
885
886 return $this;
887 }
888
893 public function withBusinessUnit(?BusinessUnitKeyReference $businessUnit)
894 {
895 $this->businessUnit = $businessUnit;
896
897 return $this;
898 }
899
904 public function withStore(?StoreKeyReference $store)
905 {
906 $this->store = $store;
907
908 return $this;
909 }
910
915 public function withLineItems(?LineItemCollection $lineItems)
916 {
917 $this->lineItems = $lineItems;
918
919 return $this;
920 }
921
926 public function withCustomLineItems(?CustomLineItemCollection $customLineItems)
927 {
928 $this->customLineItems = $customLineItems;
929
930 return $this;
931 }
932
937 public function withTotalLineItemQuantity(?int $totalLineItemQuantity)
938 {
939 $this->totalLineItemQuantity = $totalLineItemQuantity;
940
941 return $this;
942 }
943
948 public function withTotalPrice(?CentPrecisionMoney $totalPrice)
949 {
950 $this->totalPrice = $totalPrice;
951
952 return $this;
953 }
954
959 public function withTaxedPrice(?TaxedPrice $taxedPrice)
960 {
961 $this->taxedPrice = $taxedPrice;
962
963 return $this;
964 }
965
970 public function withTaxedShippingPrice(?TaxedPrice $taxedShippingPrice)
971 {
972 $this->taxedShippingPrice = $taxedShippingPrice;
973
974 return $this;
975 }
976
981 public function withDiscountOnTotalPrice(?DiscountOnTotalPrice $discountOnTotalPrice)
982 {
983 $this->discountOnTotalPrice = $discountOnTotalPrice;
984
985 return $this;
986 }
987
992 public function withTaxMode(?string $taxMode)
993 {
994 $this->taxMode = $taxMode;
995
996 return $this;
997 }
998
1003 public function withTaxRoundingMode(?string $taxRoundingMode)
1004 {
1005 $this->taxRoundingMode = $taxRoundingMode;
1006
1007 return $this;
1008 }
1009
1014 public function withTaxCalculationMode(?string $taxCalculationMode)
1015 {
1016 $this->taxCalculationMode = $taxCalculationMode;
1017
1018 return $this;
1019 }
1020
1025 public function withInventoryMode(?string $inventoryMode)
1026 {
1027 $this->inventoryMode = $inventoryMode;
1028
1029 return $this;
1030 }
1031
1036 public function withCartState(?string $cartState)
1037 {
1038 $this->cartState = $cartState;
1039
1040 return $this;
1041 }
1042
1047 public function withBillingAddress(?Address $billingAddress)
1048 {
1049 $this->billingAddress = $billingAddress;
1050
1051 return $this;
1052 }
1053
1058 public function withShippingAddress(?Address $shippingAddress)
1059 {
1060 $this->shippingAddress = $shippingAddress;
1061
1062 return $this;
1063 }
1064
1069 public function withShippingMode(?string $shippingMode)
1070 {
1071 $this->shippingMode = $shippingMode;
1072
1073 return $this;
1074 }
1075
1080 public function withShippingKey(?string $shippingKey)
1081 {
1082 $this->shippingKey = $shippingKey;
1083
1084 return $this;
1085 }
1086
1091 public function withShippingInfo(?ShippingInfo $shippingInfo)
1092 {
1093 $this->shippingInfo = $shippingInfo;
1094
1095 return $this;
1096 }
1097
1102 public function withShippingRateInput(?ShippingRateInput $shippingRateInput)
1103 {
1104 $this->shippingRateInput = $shippingRateInput;
1105
1106 return $this;
1107 }
1108
1113 public function withShippingCustomFields(?CustomFields $shippingCustomFields)
1114 {
1115 $this->shippingCustomFields = $shippingCustomFields;
1116
1117 return $this;
1118 }
1119
1124 public function withShipping(?ShippingCollection $shipping)
1125 {
1126 $this->shipping = $shipping;
1127
1128 return $this;
1129 }
1130
1135 public function withItemShippingAddresses(?AddressCollection $itemShippingAddresses)
1136 {
1137 $this->itemShippingAddresses = $itemShippingAddresses;
1138
1139 return $this;
1140 }
1141
1146 public function withDiscountCodes(?DiscountCodeInfoCollection $discountCodes)
1147 {
1148 $this->discountCodes = $discountCodes;
1149
1150 return $this;
1151 }
1152
1157 public function withDirectDiscounts(?DirectDiscountCollection $directDiscounts)
1158 {
1159 $this->directDiscounts = $directDiscounts;
1160
1161 return $this;
1162 }
1163
1169 {
1170 $this->refusedGifts = $refusedGifts;
1171
1172 return $this;
1173 }
1174
1179 public function withPaymentInfo(?PaymentInfo $paymentInfo)
1180 {
1181 $this->paymentInfo = $paymentInfo;
1182
1183 return $this;
1184 }
1185
1190 public function withCountry(?string $country)
1191 {
1192 $this->country = $country;
1193
1194 return $this;
1195 }
1196
1201 public function withLocale(?string $locale)
1202 {
1203 $this->locale = $locale;
1204
1205 return $this;
1206 }
1207
1212 public function withOrigin(?string $origin)
1213 {
1214 $this->origin = $origin;
1215
1216 return $this;
1217 }
1218
1223 public function withCustom(?CustomFields $custom)
1224 {
1225 $this->custom = $custom;
1226
1227 return $this;
1228 }
1229
1234 public function withDeleteDaysAfterLastModification(?int $deleteDaysAfterLastModification)
1235 {
1236 $this->deleteDaysAfterLastModification = $deleteDaysAfterLastModification;
1237
1238 return $this;
1239 }
1240
1245 public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
1246 {
1247 $this->lastModifiedBy = $lastModifiedBy;
1248
1249 return $this;
1250 }
1251
1256 public function withCreatedBy(?CreatedBy $createdBy)
1257 {
1258 $this->createdBy = $createdBy;
1259
1260 return $this;
1261 }
1262
1268 {
1269 $this->customerGroup = $customerGroup;
1270
1271 return $this;
1272 }
1273
1279 {
1280 $this->businessUnit = $businessUnit;
1281
1282 return $this;
1283 }
1284
1290 {
1291 $this->store = $store;
1292
1293 return $this;
1294 }
1295
1301 {
1302 $this->totalPrice = $totalPrice;
1303
1304 return $this;
1305 }
1306
1311 public function withTaxedPriceBuilder(?TaxedPriceBuilder $taxedPrice)
1312 {
1313 $this->taxedPrice = $taxedPrice;
1314
1315 return $this;
1316 }
1317
1322 public function withTaxedShippingPriceBuilder(?TaxedPriceBuilder $taxedShippingPrice)
1323 {
1324 $this->taxedShippingPrice = $taxedShippingPrice;
1325
1326 return $this;
1327 }
1328
1333 public function withDiscountOnTotalPriceBuilder(?DiscountOnTotalPriceBuilder $discountOnTotalPrice)
1334 {
1335 $this->discountOnTotalPrice = $discountOnTotalPrice;
1336
1337 return $this;
1338 }
1339
1344 public function withBillingAddressBuilder(?AddressBuilder $billingAddress)
1345 {
1346 $this->billingAddress = $billingAddress;
1347
1348 return $this;
1349 }
1350
1355 public function withShippingAddressBuilder(?AddressBuilder $shippingAddress)
1356 {
1357 $this->shippingAddress = $shippingAddress;
1358
1359 return $this;
1360 }
1361
1366 public function withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
1367 {
1368 $this->shippingInfo = $shippingInfo;
1369
1370 return $this;
1371 }
1372
1377 public function withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
1378 {
1379 $this->shippingRateInput = $shippingRateInput;
1380
1381 return $this;
1382 }
1383
1388 public function withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
1389 {
1390 $this->shippingCustomFields = $shippingCustomFields;
1391
1392 return $this;
1393 }
1394
1399 public function withPaymentInfoBuilder(?PaymentInfoBuilder $paymentInfo)
1400 {
1401 $this->paymentInfo = $paymentInfo;
1402
1403 return $this;
1404 }
1405
1410 public function withCustomBuilder(?CustomFieldsBuilder $custom)
1411 {
1412 $this->custom = $custom;
1413
1414 return $this;
1415 }
1416
1421 public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
1422 {
1423 $this->lastModifiedBy = $lastModifiedBy;
1424
1425 return $this;
1426 }
1427
1432 public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
1433 {
1434 $this->createdBy = $createdBy;
1435
1436 return $this;
1437 }
1438
1439 public function build(): Cart
1440 {
1441 return new CartModel(
1442 $this->id,
1443 $this->version,
1444 $this->createdAt,
1445 $this->lastModifiedAt,
1446 $this->key,
1447 $this->customerId,
1448 $this->customerEmail,
1449 $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup,
1450 $this->anonymousId,
1451 $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit,
1452 $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store,
1453 $this->lineItems,
1454 $this->customLineItems,
1455 $this->totalLineItemQuantity,
1456 $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice,
1457 $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice,
1458 $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice,
1459 $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice,
1460 $this->taxMode,
1461 $this->taxRoundingMode,
1462 $this->taxCalculationMode,
1463 $this->inventoryMode,
1464 $this->cartState,
1465 $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress,
1466 $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress,
1467 $this->shippingMode,
1468 $this->shippingKey,
1469 $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo,
1470 $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput,
1471 $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields,
1472 $this->shipping,
1473 $this->itemShippingAddresses,
1474 $this->discountCodes,
1475 $this->directDiscounts,
1476 $this->refusedGifts,
1477 $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo,
1478 $this->country,
1479 $this->locale,
1480 $this->origin,
1481 $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom,
1482 $this->deleteDaysAfterLastModification,
1483 $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
1484 $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy
1485 );
1486 }
1487
1488 public static function of(): CartBuilder
1489 {
1490 return new self();
1491 }
1492}
withTotalPriceBuilder(?CentPrecisionMoneyBuilder $totalPrice)
withShippingAddressBuilder(?AddressBuilder $shippingAddress)
withLineItems(?LineItemCollection $lineItems)
withTaxedPriceBuilder(?TaxedPriceBuilder $taxedPrice)
withTaxedPrice(?TaxedPrice $taxedPrice)
withBusinessUnit(?BusinessUnitKeyReference $businessUnit)
withTaxCalculationMode(?string $taxCalculationMode)
withShippingRateInput(?ShippingRateInput $shippingRateInput)
withRefusedGifts(?CartDiscountReferenceCollection $refusedGifts)
withCustomerGroup(?CustomerGroupReference $customerGroup)
withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
withStoreBuilder(?StoreKeyReferenceBuilder $store)
withShippingInfo(?ShippingInfo $shippingInfo)
withShipping(?ShippingCollection $shipping)
withDiscountCodes(?DiscountCodeInfoCollection $discountCodes)
withBusinessUnitBuilder(?BusinessUnitKeyReferenceBuilder $businessUnit)
withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
withDiscountOnTotalPrice(?DiscountOnTotalPrice $discountOnTotalPrice)
withDirectDiscounts(?DirectDiscountCollection $directDiscounts)
withTaxRoundingMode(?string $taxRoundingMode)
withCustomLineItems(?CustomLineItemCollection $customLineItems)
withBillingAddressBuilder(?AddressBuilder $billingAddress)
withDeleteDaysAfterLastModification(?int $deleteDaysAfterLastModification)
withPaymentInfo(?PaymentInfo $paymentInfo)
withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
withCreatedAt(?DateTimeImmutable $createdAt)
withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
withTotalLineItemQuantity(?int $totalLineItemQuantity)
withShippingCustomFields(?CustomFields $shippingCustomFields)
withTaxedShippingPrice(?TaxedPrice $taxedShippingPrice)
withShippingAddress(?Address $shippingAddress)
withTaxedShippingPriceBuilder(?TaxedPriceBuilder $taxedShippingPrice)
withCreatedByBuilder(?CreatedByBuilder $createdBy)
withDiscountOnTotalPriceBuilder(?DiscountOnTotalPriceBuilder $discountOnTotalPrice)
withTotalPrice(?CentPrecisionMoney $totalPrice)
withItemShippingAddresses(?AddressCollection $itemShippingAddresses)
withBillingAddress(?Address $billingAddress)
withCustomerGroupBuilder(?CustomerGroupReferenceBuilder $customerGroup)
withStore(?StoreKeyReference $store)
withPaymentInfoBuilder(?PaymentInfoBuilder $paymentInfo)
withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
withCustomBuilder(?CustomFieldsBuilder $custom)
withCustomerEmail(?string $customerEmail)