commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
All Classes Namespaces Functions Variables Pages
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 $discountTypeCombination;
291
296 private $deleteDaysAfterLastModification;
297
302 private $lastModifiedBy;
303
308 private $createdBy;
309
316 public function getId()
317 {
318 return $this->id;
319 }
320
327 public function getVersion()
328 {
329 return $this->version;
330 }
331
338 public function getCreatedAt()
339 {
340 return $this->createdAt;
341 }
342
349 public function getLastModifiedAt()
350 {
351 return $this->lastModifiedAt;
352 }
353
360 public function getKey()
361 {
362 return $this->key;
363 }
364
371 public function getCustomerId()
372 {
373 return $this->customerId;
374 }
375
382 public function getCustomerEmail()
383 {
384 return $this->customerEmail;
385 }
386
393 public function getCustomerGroup()
394 {
395 return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup;
396 }
397
404 public function getAnonymousId()
405 {
406 return $this->anonymousId;
407 }
408
415 public function getBusinessUnit()
416 {
417 return $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit;
418 }
419
426 public function getStore()
427 {
428 return $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store;
429 }
430
437 public function getLineItems()
438 {
439 return $this->lineItems;
440 }
441
448 public function getCustomLineItems()
449 {
450 return $this->customLineItems;
451 }
452
459 public function getTotalLineItemQuantity()
460 {
461 return $this->totalLineItemQuantity;
462 }
463
472 public function getTotalPrice()
473 {
474 return $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice;
475 }
476
487 public function getTaxedPrice()
488 {
489 return $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice;
490 }
491
498 public function getTaxedShippingPrice()
499 {
500 return $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice;
501 }
502
509 public function getDiscountOnTotalPrice()
510 {
511 return $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice;
512 }
513
520 public function getTaxMode()
521 {
522 return $this->taxMode;
523 }
524
531 public function getTaxRoundingMode()
532 {
533 return $this->taxRoundingMode;
534 }
535
542 public function getTaxCalculationMode()
543 {
544 return $this->taxCalculationMode;
545 }
546
553 public function getInventoryMode()
554 {
555 return $this->inventoryMode;
556 }
557
564 public function getCartState()
565 {
566 return $this->cartState;
567 }
568
575 public function getBillingAddress()
576 {
577 return $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress;
578 }
579
586 public function getShippingAddress()
587 {
588 return $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress;
589 }
590
597 public function getShippingMode()
598 {
599 return $this->shippingMode;
600 }
601
608 public function getShippingKey()
609 {
610 return $this->shippingKey;
611 }
612
619 public function getShippingInfo()
620 {
621 return $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo;
622 }
623
636 public function getShippingRateInput()
637 {
638 return $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput;
639 }
640
647 public function getShippingCustomFields()
648 {
649 return $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields;
650 }
651
658 public function getShipping()
659 {
660 return $this->shipping;
661 }
662
670 public function getItemShippingAddresses()
671 {
672 return $this->itemShippingAddresses;
673 }
674
681 public function getDiscountCodes()
682 {
683 return $this->discountCodes;
684 }
685
692 public function getDirectDiscounts()
693 {
694 return $this->directDiscounts;
695 }
696
703 public function getRefusedGifts()
704 {
705 return $this->refusedGifts;
706 }
707
714 public function getPaymentInfo()
715 {
716 return $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo;
717 }
718
725 public function getCountry()
726 {
727 return $this->country;
728 }
729
736 public function getLocale()
737 {
738 return $this->locale;
739 }
740
747 public function getOrigin()
748 {
749 return $this->origin;
750 }
751
758 public function getCustom()
759 {
760 return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
761 }
762
770 {
771 return $this->discountTypeCombination instanceof DiscountTypeCombinationBuilder ? $this->discountTypeCombination->build() : $this->discountTypeCombination;
772 }
773
781 {
782 return $this->deleteDaysAfterLastModification;
783 }
784
791 public function getLastModifiedBy()
792 {
793 return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
794 }
795
802 public function getCreatedBy()
803 {
804 return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
805 }
806
811 public function withId(?string $id)
812 {
813 $this->id = $id;
814
815 return $this;
816 }
817
822 public function withVersion(?int $version)
823 {
824 $this->version = $version;
825
826 return $this;
827 }
828
833 public function withCreatedAt(?DateTimeImmutable $createdAt)
834 {
835 $this->createdAt = $createdAt;
836
837 return $this;
838 }
839
844 public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
845 {
846 $this->lastModifiedAt = $lastModifiedAt;
847
848 return $this;
849 }
850
855 public function withKey(?string $key)
856 {
857 $this->key = $key;
858
859 return $this;
860 }
861
866 public function withCustomerId(?string $customerId)
867 {
868 $this->customerId = $customerId;
869
870 return $this;
871 }
872
877 public function withCustomerEmail(?string $customerEmail)
878 {
879 $this->customerEmail = $customerEmail;
880
881 return $this;
882 }
883
888 public function withCustomerGroup(?CustomerGroupReference $customerGroup)
889 {
890 $this->customerGroup = $customerGroup;
891
892 return $this;
893 }
894
899 public function withAnonymousId(?string $anonymousId)
900 {
901 $this->anonymousId = $anonymousId;
902
903 return $this;
904 }
905
910 public function withBusinessUnit(?BusinessUnitKeyReference $businessUnit)
911 {
912 $this->businessUnit = $businessUnit;
913
914 return $this;
915 }
916
921 public function withStore(?StoreKeyReference $store)
922 {
923 $this->store = $store;
924
925 return $this;
926 }
927
932 public function withLineItems(?LineItemCollection $lineItems)
933 {
934 $this->lineItems = $lineItems;
935
936 return $this;
937 }
938
943 public function withCustomLineItems(?CustomLineItemCollection $customLineItems)
944 {
945 $this->customLineItems = $customLineItems;
946
947 return $this;
948 }
949
954 public function withTotalLineItemQuantity(?int $totalLineItemQuantity)
955 {
956 $this->totalLineItemQuantity = $totalLineItemQuantity;
957
958 return $this;
959 }
960
965 public function withTotalPrice(?CentPrecisionMoney $totalPrice)
966 {
967 $this->totalPrice = $totalPrice;
968
969 return $this;
970 }
971
976 public function withTaxedPrice(?TaxedPrice $taxedPrice)
977 {
978 $this->taxedPrice = $taxedPrice;
979
980 return $this;
981 }
982
987 public function withTaxedShippingPrice(?TaxedPrice $taxedShippingPrice)
988 {
989 $this->taxedShippingPrice = $taxedShippingPrice;
990
991 return $this;
992 }
993
998 public function withDiscountOnTotalPrice(?DiscountOnTotalPrice $discountOnTotalPrice)
999 {
1000 $this->discountOnTotalPrice = $discountOnTotalPrice;
1001
1002 return $this;
1003 }
1004
1009 public function withTaxMode(?string $taxMode)
1010 {
1011 $this->taxMode = $taxMode;
1012
1013 return $this;
1014 }
1015
1020 public function withTaxRoundingMode(?string $taxRoundingMode)
1021 {
1022 $this->taxRoundingMode = $taxRoundingMode;
1023
1024 return $this;
1025 }
1026
1031 public function withTaxCalculationMode(?string $taxCalculationMode)
1032 {
1033 $this->taxCalculationMode = $taxCalculationMode;
1034
1035 return $this;
1036 }
1037
1042 public function withInventoryMode(?string $inventoryMode)
1043 {
1044 $this->inventoryMode = $inventoryMode;
1045
1046 return $this;
1047 }
1048
1053 public function withCartState(?string $cartState)
1054 {
1055 $this->cartState = $cartState;
1056
1057 return $this;
1058 }
1059
1064 public function withBillingAddress(?Address $billingAddress)
1065 {
1066 $this->billingAddress = $billingAddress;
1067
1068 return $this;
1069 }
1070
1075 public function withShippingAddress(?Address $shippingAddress)
1076 {
1077 $this->shippingAddress = $shippingAddress;
1078
1079 return $this;
1080 }
1081
1086 public function withShippingMode(?string $shippingMode)
1087 {
1088 $this->shippingMode = $shippingMode;
1089
1090 return $this;
1091 }
1092
1097 public function withShippingKey(?string $shippingKey)
1098 {
1099 $this->shippingKey = $shippingKey;
1100
1101 return $this;
1102 }
1103
1108 public function withShippingInfo(?ShippingInfo $shippingInfo)
1109 {
1110 $this->shippingInfo = $shippingInfo;
1111
1112 return $this;
1113 }
1114
1119 public function withShippingRateInput(?ShippingRateInput $shippingRateInput)
1120 {
1121 $this->shippingRateInput = $shippingRateInput;
1122
1123 return $this;
1124 }
1125
1130 public function withShippingCustomFields(?CustomFields $shippingCustomFields)
1131 {
1132 $this->shippingCustomFields = $shippingCustomFields;
1133
1134 return $this;
1135 }
1136
1141 public function withShipping(?ShippingCollection $shipping)
1142 {
1143 $this->shipping = $shipping;
1144
1145 return $this;
1146 }
1147
1152 public function withItemShippingAddresses(?AddressCollection $itemShippingAddresses)
1153 {
1154 $this->itemShippingAddresses = $itemShippingAddresses;
1155
1156 return $this;
1157 }
1158
1163 public function withDiscountCodes(?DiscountCodeInfoCollection $discountCodes)
1164 {
1165 $this->discountCodes = $discountCodes;
1166
1167 return $this;
1168 }
1169
1174 public function withDirectDiscounts(?DirectDiscountCollection $directDiscounts)
1175 {
1176 $this->directDiscounts = $directDiscounts;
1177
1178 return $this;
1179 }
1180
1186 {
1187 $this->refusedGifts = $refusedGifts;
1188
1189 return $this;
1190 }
1191
1196 public function withPaymentInfo(?PaymentInfo $paymentInfo)
1197 {
1198 $this->paymentInfo = $paymentInfo;
1199
1200 return $this;
1201 }
1202
1207 public function withCountry(?string $country)
1208 {
1209 $this->country = $country;
1210
1211 return $this;
1212 }
1213
1218 public function withLocale(?string $locale)
1219 {
1220 $this->locale = $locale;
1221
1222 return $this;
1223 }
1224
1229 public function withOrigin(?string $origin)
1230 {
1231 $this->origin = $origin;
1232
1233 return $this;
1234 }
1235
1240 public function withCustom(?CustomFields $custom)
1241 {
1242 $this->custom = $custom;
1243
1244 return $this;
1245 }
1246
1251 public function withDiscountTypeCombination(?DiscountTypeCombination $discountTypeCombination)
1252 {
1253 $this->discountTypeCombination = $discountTypeCombination;
1254
1255 return $this;
1256 }
1257
1262 public function withDeleteDaysAfterLastModification(?int $deleteDaysAfterLastModification)
1263 {
1264 $this->deleteDaysAfterLastModification = $deleteDaysAfterLastModification;
1265
1266 return $this;
1267 }
1268
1273 public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
1274 {
1275 $this->lastModifiedBy = $lastModifiedBy;
1276
1277 return $this;
1278 }
1279
1284 public function withCreatedBy(?CreatedBy $createdBy)
1285 {
1286 $this->createdBy = $createdBy;
1287
1288 return $this;
1289 }
1290
1296 {
1297 $this->customerGroup = $customerGroup;
1298
1299 return $this;
1300 }
1301
1307 {
1308 $this->businessUnit = $businessUnit;
1309
1310 return $this;
1311 }
1312
1318 {
1319 $this->store = $store;
1320
1321 return $this;
1322 }
1323
1329 {
1330 $this->totalPrice = $totalPrice;
1331
1332 return $this;
1333 }
1334
1339 public function withTaxedPriceBuilder(?TaxedPriceBuilder $taxedPrice)
1340 {
1341 $this->taxedPrice = $taxedPrice;
1342
1343 return $this;
1344 }
1345
1350 public function withTaxedShippingPriceBuilder(?TaxedPriceBuilder $taxedShippingPrice)
1351 {
1352 $this->taxedShippingPrice = $taxedShippingPrice;
1353
1354 return $this;
1355 }
1356
1361 public function withDiscountOnTotalPriceBuilder(?DiscountOnTotalPriceBuilder $discountOnTotalPrice)
1362 {
1363 $this->discountOnTotalPrice = $discountOnTotalPrice;
1364
1365 return $this;
1366 }
1367
1372 public function withBillingAddressBuilder(?AddressBuilder $billingAddress)
1373 {
1374 $this->billingAddress = $billingAddress;
1375
1376 return $this;
1377 }
1378
1383 public function withShippingAddressBuilder(?AddressBuilder $shippingAddress)
1384 {
1385 $this->shippingAddress = $shippingAddress;
1386
1387 return $this;
1388 }
1389
1394 public function withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
1395 {
1396 $this->shippingInfo = $shippingInfo;
1397
1398 return $this;
1399 }
1400
1405 public function withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
1406 {
1407 $this->shippingRateInput = $shippingRateInput;
1408
1409 return $this;
1410 }
1411
1416 public function withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
1417 {
1418 $this->shippingCustomFields = $shippingCustomFields;
1419
1420 return $this;
1421 }
1422
1427 public function withPaymentInfoBuilder(?PaymentInfoBuilder $paymentInfo)
1428 {
1429 $this->paymentInfo = $paymentInfo;
1430
1431 return $this;
1432 }
1433
1438 public function withCustomBuilder(?CustomFieldsBuilder $custom)
1439 {
1440 $this->custom = $custom;
1441
1442 return $this;
1443 }
1444
1450 {
1451 $this->discountTypeCombination = $discountTypeCombination;
1452
1453 return $this;
1454 }
1455
1460 public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
1461 {
1462 $this->lastModifiedBy = $lastModifiedBy;
1463
1464 return $this;
1465 }
1466
1471 public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
1472 {
1473 $this->createdBy = $createdBy;
1474
1475 return $this;
1476 }
1477
1478 public function build(): Cart
1479 {
1480 return new CartModel(
1481 $this->id,
1482 $this->version,
1483 $this->createdAt,
1484 $this->lastModifiedAt,
1485 $this->key,
1486 $this->customerId,
1487 $this->customerEmail,
1488 $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup,
1489 $this->anonymousId,
1490 $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit,
1491 $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store,
1492 $this->lineItems,
1493 $this->customLineItems,
1494 $this->totalLineItemQuantity,
1495 $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice,
1496 $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice,
1497 $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice,
1498 $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice,
1499 $this->taxMode,
1500 $this->taxRoundingMode,
1501 $this->taxCalculationMode,
1502 $this->inventoryMode,
1503 $this->cartState,
1504 $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress,
1505 $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress,
1506 $this->shippingMode,
1507 $this->shippingKey,
1508 $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo,
1509 $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput,
1510 $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields,
1511 $this->shipping,
1512 $this->itemShippingAddresses,
1513 $this->discountCodes,
1514 $this->directDiscounts,
1515 $this->refusedGifts,
1516 $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo,
1517 $this->country,
1518 $this->locale,
1519 $this->origin,
1520 $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom,
1521 $this->discountTypeCombination instanceof DiscountTypeCombinationBuilder ? $this->discountTypeCombination->build() : $this->discountTypeCombination,
1522 $this->deleteDaysAfterLastModification,
1523 $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
1524 $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy
1525 );
1526 }
1527
1528 public static function of(): CartBuilder
1529 {
1530 return new self();
1531 }
1532}
withDiscountTypeCombination(?DiscountTypeCombination $discountTypeCombination)
withTotalPriceBuilder(?CentPrecisionMoneyBuilder $totalPrice)
withShippingAddressBuilder(?AddressBuilder $shippingAddress)
withLineItems(?LineItemCollection $lineItems)
withTaxedPriceBuilder(?TaxedPriceBuilder $taxedPrice)
withTaxedPrice(?TaxedPrice $taxedPrice)
withBusinessUnit(?BusinessUnitKeyReference $businessUnit)
withDiscountTypeCombinationBuilder(?DiscountTypeCombinationBuilder $discountTypeCombination)
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)