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 $priceRoundingMode;
165
170 private $taxRoundingMode;
171
176 private $taxCalculationMode;
177
182 private $inventoryMode;
183
188 private $cartState;
189
194 private $billingAddress;
195
200 private $shippingAddress;
201
206 private $shippingMode;
207
212 private $shippingKey;
213
218 private $shippingInfo;
219
224 private $shippingRateInput;
225
230 private $shippingCustomFields;
231
236 private $shipping;
237
242 private $itemShippingAddresses;
243
248 private $discountCodes;
249
254 private $directDiscounts;
255
260 private $refusedGifts;
261
266 private $paymentInfo;
267
272 private $country;
273
278 private $locale;
279
284 private $origin;
285
290 private $custom;
291
296 private $discountTypeCombination;
297
302 private $deleteDaysAfterLastModification;
303
308 private $lastModifiedBy;
309
314 private $createdBy;
315
322 public function getId()
323 {
324 return $this->id;
325 }
326
333 public function getVersion()
334 {
335 return $this->version;
336 }
337
344 public function getCreatedAt()
345 {
346 return $this->createdAt;
347 }
348
355 public function getLastModifiedAt()
356 {
357 return $this->lastModifiedAt;
358 }
359
366 public function getKey()
367 {
368 return $this->key;
369 }
370
377 public function getCustomerId()
378 {
379 return $this->customerId;
380 }
381
388 public function getCustomerEmail()
389 {
390 return $this->customerEmail;
391 }
392
399 public function getCustomerGroup()
400 {
401 return $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup;
402 }
403
410 public function getAnonymousId()
411 {
412 return $this->anonymousId;
413 }
414
421 public function getBusinessUnit()
422 {
423 return $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit;
424 }
425
432 public function getStore()
433 {
434 return $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store;
435 }
436
443 public function getLineItems()
444 {
445 return $this->lineItems;
446 }
447
454 public function getCustomLineItems()
455 {
456 return $this->customLineItems;
457 }
458
465 public function getTotalLineItemQuantity()
466 {
467 return $this->totalLineItemQuantity;
468 }
469
478 public function getTotalPrice()
479 {
480 return $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice;
481 }
482
493 public function getTaxedPrice()
494 {
495 return $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice;
496 }
497
505 public function getTaxedShippingPrice()
506 {
507 return $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice;
508 }
509
516 public function getDiscountOnTotalPrice()
517 {
518 return $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice;
519 }
520
527 public function getTaxMode()
528 {
529 return $this->taxMode;
530 }
531
538 public function getPriceRoundingMode()
539 {
540 return $this->priceRoundingMode;
541 }
542
549 public function getTaxRoundingMode()
550 {
551 return $this->taxRoundingMode;
552 }
553
560 public function getTaxCalculationMode()
561 {
562 return $this->taxCalculationMode;
563 }
564
571 public function getInventoryMode()
572 {
573 return $this->inventoryMode;
574 }
575
582 public function getCartState()
583 {
584 return $this->cartState;
585 }
586
593 public function getBillingAddress()
594 {
595 return $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress;
596 }
597
604 public function getShippingAddress()
605 {
606 return $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress;
607 }
608
615 public function getShippingMode()
616 {
617 return $this->shippingMode;
618 }
619
626 public function getShippingKey()
627 {
628 return $this->shippingKey;
629 }
630
637 public function getShippingInfo()
638 {
639 return $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo;
640 }
641
654 public function getShippingRateInput()
655 {
656 return $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput;
657 }
658
665 public function getShippingCustomFields()
666 {
667 return $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields;
668 }
669
676 public function getShipping()
677 {
678 return $this->shipping;
679 }
680
688 public function getItemShippingAddresses()
689 {
690 return $this->itemShippingAddresses;
691 }
692
699 public function getDiscountCodes()
700 {
701 return $this->discountCodes;
702 }
703
710 public function getDirectDiscounts()
711 {
712 return $this->directDiscounts;
713 }
714
721 public function getRefusedGifts()
722 {
723 return $this->refusedGifts;
724 }
725
732 public function getPaymentInfo()
733 {
734 return $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo;
735 }
736
743 public function getCountry()
744 {
745 return $this->country;
746 }
747
754 public function getLocale()
755 {
756 return $this->locale;
757 }
758
765 public function getOrigin()
766 {
767 return $this->origin;
768 }
769
776 public function getCustom()
777 {
778 return $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom;
779 }
780
788 {
789 return $this->discountTypeCombination instanceof DiscountTypeCombinationBuilder ? $this->discountTypeCombination->build() : $this->discountTypeCombination;
790 }
791
799 {
800 return $this->deleteDaysAfterLastModification;
801 }
802
809 public function getLastModifiedBy()
810 {
811 return $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy;
812 }
813
820 public function getCreatedBy()
821 {
822 return $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy;
823 }
824
829 public function withId(?string $id)
830 {
831 $this->id = $id;
832
833 return $this;
834 }
835
840 public function withVersion(?int $version)
841 {
842 $this->version = $version;
843
844 return $this;
845 }
846
851 public function withCreatedAt(?DateTimeImmutable $createdAt)
852 {
853 $this->createdAt = $createdAt;
854
855 return $this;
856 }
857
862 public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt)
863 {
864 $this->lastModifiedAt = $lastModifiedAt;
865
866 return $this;
867 }
868
873 public function withKey(?string $key)
874 {
875 $this->key = $key;
876
877 return $this;
878 }
879
884 public function withCustomerId(?string $customerId)
885 {
886 $this->customerId = $customerId;
887
888 return $this;
889 }
890
895 public function withCustomerEmail(?string $customerEmail)
896 {
897 $this->customerEmail = $customerEmail;
898
899 return $this;
900 }
901
906 public function withCustomerGroup(?CustomerGroupReference $customerGroup)
907 {
908 $this->customerGroup = $customerGroup;
909
910 return $this;
911 }
912
917 public function withAnonymousId(?string $anonymousId)
918 {
919 $this->anonymousId = $anonymousId;
920
921 return $this;
922 }
923
928 public function withBusinessUnit(?BusinessUnitKeyReference $businessUnit)
929 {
930 $this->businessUnit = $businessUnit;
931
932 return $this;
933 }
934
939 public function withStore(?StoreKeyReference $store)
940 {
941 $this->store = $store;
942
943 return $this;
944 }
945
950 public function withLineItems(?LineItemCollection $lineItems)
951 {
952 $this->lineItems = $lineItems;
953
954 return $this;
955 }
956
961 public function withCustomLineItems(?CustomLineItemCollection $customLineItems)
962 {
963 $this->customLineItems = $customLineItems;
964
965 return $this;
966 }
967
972 public function withTotalLineItemQuantity(?int $totalLineItemQuantity)
973 {
974 $this->totalLineItemQuantity = $totalLineItemQuantity;
975
976 return $this;
977 }
978
983 public function withTotalPrice(?CentPrecisionMoney $totalPrice)
984 {
985 $this->totalPrice = $totalPrice;
986
987 return $this;
988 }
989
994 public function withTaxedPrice(?TaxedPrice $taxedPrice)
995 {
996 $this->taxedPrice = $taxedPrice;
997
998 return $this;
999 }
1000
1005 public function withTaxedShippingPrice(?TaxedPrice $taxedShippingPrice)
1006 {
1007 $this->taxedShippingPrice = $taxedShippingPrice;
1008
1009 return $this;
1010 }
1011
1016 public function withDiscountOnTotalPrice(?DiscountOnTotalPrice $discountOnTotalPrice)
1017 {
1018 $this->discountOnTotalPrice = $discountOnTotalPrice;
1019
1020 return $this;
1021 }
1022
1027 public function withTaxMode(?string $taxMode)
1028 {
1029 $this->taxMode = $taxMode;
1030
1031 return $this;
1032 }
1033
1038 public function withPriceRoundingMode(?string $priceRoundingMode)
1039 {
1040 $this->priceRoundingMode = $priceRoundingMode;
1041
1042 return $this;
1043 }
1044
1049 public function withTaxRoundingMode(?string $taxRoundingMode)
1050 {
1051 $this->taxRoundingMode = $taxRoundingMode;
1052
1053 return $this;
1054 }
1055
1060 public function withTaxCalculationMode(?string $taxCalculationMode)
1061 {
1062 $this->taxCalculationMode = $taxCalculationMode;
1063
1064 return $this;
1065 }
1066
1071 public function withInventoryMode(?string $inventoryMode)
1072 {
1073 $this->inventoryMode = $inventoryMode;
1074
1075 return $this;
1076 }
1077
1082 public function withCartState(?string $cartState)
1083 {
1084 $this->cartState = $cartState;
1085
1086 return $this;
1087 }
1088
1093 public function withBillingAddress(?Address $billingAddress)
1094 {
1095 $this->billingAddress = $billingAddress;
1096
1097 return $this;
1098 }
1099
1104 public function withShippingAddress(?Address $shippingAddress)
1105 {
1106 $this->shippingAddress = $shippingAddress;
1107
1108 return $this;
1109 }
1110
1115 public function withShippingMode(?string $shippingMode)
1116 {
1117 $this->shippingMode = $shippingMode;
1118
1119 return $this;
1120 }
1121
1126 public function withShippingKey(?string $shippingKey)
1127 {
1128 $this->shippingKey = $shippingKey;
1129
1130 return $this;
1131 }
1132
1137 public function withShippingInfo(?ShippingInfo $shippingInfo)
1138 {
1139 $this->shippingInfo = $shippingInfo;
1140
1141 return $this;
1142 }
1143
1148 public function withShippingRateInput(?ShippingRateInput $shippingRateInput)
1149 {
1150 $this->shippingRateInput = $shippingRateInput;
1151
1152 return $this;
1153 }
1154
1159 public function withShippingCustomFields(?CustomFields $shippingCustomFields)
1160 {
1161 $this->shippingCustomFields = $shippingCustomFields;
1162
1163 return $this;
1164 }
1165
1170 public function withShipping(?ShippingCollection $shipping)
1171 {
1172 $this->shipping = $shipping;
1173
1174 return $this;
1175 }
1176
1181 public function withItemShippingAddresses(?AddressCollection $itemShippingAddresses)
1182 {
1183 $this->itemShippingAddresses = $itemShippingAddresses;
1184
1185 return $this;
1186 }
1187
1192 public function withDiscountCodes(?DiscountCodeInfoCollection $discountCodes)
1193 {
1194 $this->discountCodes = $discountCodes;
1195
1196 return $this;
1197 }
1198
1203 public function withDirectDiscounts(?DirectDiscountCollection $directDiscounts)
1204 {
1205 $this->directDiscounts = $directDiscounts;
1206
1207 return $this;
1208 }
1209
1215 {
1216 $this->refusedGifts = $refusedGifts;
1217
1218 return $this;
1219 }
1220
1225 public function withPaymentInfo(?PaymentInfo $paymentInfo)
1226 {
1227 $this->paymentInfo = $paymentInfo;
1228
1229 return $this;
1230 }
1231
1236 public function withCountry(?string $country)
1237 {
1238 $this->country = $country;
1239
1240 return $this;
1241 }
1242
1247 public function withLocale(?string $locale)
1248 {
1249 $this->locale = $locale;
1250
1251 return $this;
1252 }
1253
1258 public function withOrigin(?string $origin)
1259 {
1260 $this->origin = $origin;
1261
1262 return $this;
1263 }
1264
1269 public function withCustom(?CustomFields $custom)
1270 {
1271 $this->custom = $custom;
1272
1273 return $this;
1274 }
1275
1280 public function withDiscountTypeCombination(?DiscountTypeCombination $discountTypeCombination)
1281 {
1282 $this->discountTypeCombination = $discountTypeCombination;
1283
1284 return $this;
1285 }
1286
1291 public function withDeleteDaysAfterLastModification(?int $deleteDaysAfterLastModification)
1292 {
1293 $this->deleteDaysAfterLastModification = $deleteDaysAfterLastModification;
1294
1295 return $this;
1296 }
1297
1302 public function withLastModifiedBy(?LastModifiedBy $lastModifiedBy)
1303 {
1304 $this->lastModifiedBy = $lastModifiedBy;
1305
1306 return $this;
1307 }
1308
1313 public function withCreatedBy(?CreatedBy $createdBy)
1314 {
1315 $this->createdBy = $createdBy;
1316
1317 return $this;
1318 }
1319
1325 {
1326 $this->customerGroup = $customerGroup;
1327
1328 return $this;
1329 }
1330
1336 {
1337 $this->businessUnit = $businessUnit;
1338
1339 return $this;
1340 }
1341
1347 {
1348 $this->store = $store;
1349
1350 return $this;
1351 }
1352
1358 {
1359 $this->totalPrice = $totalPrice;
1360
1361 return $this;
1362 }
1363
1368 public function withTaxedPriceBuilder(?TaxedPriceBuilder $taxedPrice)
1369 {
1370 $this->taxedPrice = $taxedPrice;
1371
1372 return $this;
1373 }
1374
1379 public function withTaxedShippingPriceBuilder(?TaxedPriceBuilder $taxedShippingPrice)
1380 {
1381 $this->taxedShippingPrice = $taxedShippingPrice;
1382
1383 return $this;
1384 }
1385
1390 public function withDiscountOnTotalPriceBuilder(?DiscountOnTotalPriceBuilder $discountOnTotalPrice)
1391 {
1392 $this->discountOnTotalPrice = $discountOnTotalPrice;
1393
1394 return $this;
1395 }
1396
1401 public function withBillingAddressBuilder(?AddressBuilder $billingAddress)
1402 {
1403 $this->billingAddress = $billingAddress;
1404
1405 return $this;
1406 }
1407
1412 public function withShippingAddressBuilder(?AddressBuilder $shippingAddress)
1413 {
1414 $this->shippingAddress = $shippingAddress;
1415
1416 return $this;
1417 }
1418
1423 public function withShippingInfoBuilder(?ShippingInfoBuilder $shippingInfo)
1424 {
1425 $this->shippingInfo = $shippingInfo;
1426
1427 return $this;
1428 }
1429
1434 public function withShippingRateInputBuilder(?ShippingRateInputBuilder $shippingRateInput)
1435 {
1436 $this->shippingRateInput = $shippingRateInput;
1437
1438 return $this;
1439 }
1440
1445 public function withShippingCustomFieldsBuilder(?CustomFieldsBuilder $shippingCustomFields)
1446 {
1447 $this->shippingCustomFields = $shippingCustomFields;
1448
1449 return $this;
1450 }
1451
1456 public function withPaymentInfoBuilder(?PaymentInfoBuilder $paymentInfo)
1457 {
1458 $this->paymentInfo = $paymentInfo;
1459
1460 return $this;
1461 }
1462
1467 public function withCustomBuilder(?CustomFieldsBuilder $custom)
1468 {
1469 $this->custom = $custom;
1470
1471 return $this;
1472 }
1473
1479 {
1480 $this->discountTypeCombination = $discountTypeCombination;
1481
1482 return $this;
1483 }
1484
1489 public function withLastModifiedByBuilder(?LastModifiedByBuilder $lastModifiedBy)
1490 {
1491 $this->lastModifiedBy = $lastModifiedBy;
1492
1493 return $this;
1494 }
1495
1500 public function withCreatedByBuilder(?CreatedByBuilder $createdBy)
1501 {
1502 $this->createdBy = $createdBy;
1503
1504 return $this;
1505 }
1506
1507 public function build(): Cart
1508 {
1509 return new CartModel(
1510 $this->id,
1511 $this->version,
1512 $this->createdAt,
1513 $this->lastModifiedAt,
1514 $this->key,
1515 $this->customerId,
1516 $this->customerEmail,
1517 $this->customerGroup instanceof CustomerGroupReferenceBuilder ? $this->customerGroup->build() : $this->customerGroup,
1518 $this->anonymousId,
1519 $this->businessUnit instanceof BusinessUnitKeyReferenceBuilder ? $this->businessUnit->build() : $this->businessUnit,
1520 $this->store instanceof StoreKeyReferenceBuilder ? $this->store->build() : $this->store,
1521 $this->lineItems,
1522 $this->customLineItems,
1523 $this->totalLineItemQuantity,
1524 $this->totalPrice instanceof CentPrecisionMoneyBuilder ? $this->totalPrice->build() : $this->totalPrice,
1525 $this->taxedPrice instanceof TaxedPriceBuilder ? $this->taxedPrice->build() : $this->taxedPrice,
1526 $this->taxedShippingPrice instanceof TaxedPriceBuilder ? $this->taxedShippingPrice->build() : $this->taxedShippingPrice,
1527 $this->discountOnTotalPrice instanceof DiscountOnTotalPriceBuilder ? $this->discountOnTotalPrice->build() : $this->discountOnTotalPrice,
1528 $this->taxMode,
1529 $this->priceRoundingMode,
1530 $this->taxRoundingMode,
1531 $this->taxCalculationMode,
1532 $this->inventoryMode,
1533 $this->cartState,
1534 $this->billingAddress instanceof AddressBuilder ? $this->billingAddress->build() : $this->billingAddress,
1535 $this->shippingAddress instanceof AddressBuilder ? $this->shippingAddress->build() : $this->shippingAddress,
1536 $this->shippingMode,
1537 $this->shippingKey,
1538 $this->shippingInfo instanceof ShippingInfoBuilder ? $this->shippingInfo->build() : $this->shippingInfo,
1539 $this->shippingRateInput instanceof ShippingRateInputBuilder ? $this->shippingRateInput->build() : $this->shippingRateInput,
1540 $this->shippingCustomFields instanceof CustomFieldsBuilder ? $this->shippingCustomFields->build() : $this->shippingCustomFields,
1541 $this->shipping,
1542 $this->itemShippingAddresses,
1543 $this->discountCodes,
1544 $this->directDiscounts,
1545 $this->refusedGifts,
1546 $this->paymentInfo instanceof PaymentInfoBuilder ? $this->paymentInfo->build() : $this->paymentInfo,
1547 $this->country,
1548 $this->locale,
1549 $this->origin,
1550 $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom,
1551 $this->discountTypeCombination instanceof DiscountTypeCombinationBuilder ? $this->discountTypeCombination->build() : $this->discountTypeCombination,
1552 $this->deleteDaysAfterLastModification,
1553 $this->lastModifiedBy instanceof LastModifiedByBuilder ? $this->lastModifiedBy->build() : $this->lastModifiedBy,
1554 $this->createdBy instanceof CreatedByBuilder ? $this->createdBy->build() : $this->createdBy
1555 );
1556 }
1557
1558 public static function of(): CartBuilder
1559 {
1560 return new self();
1561 }
1562}
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)
withPriceRoundingMode(?string $priceRoundingMode)
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)