diff --git a/changes.md b/changes.md index d7c97786492..d72932ce3f7 100644 --- a/changes.md +++ b/changes.md @@ -54,6 +54,10 @@ - added property `invalidateOlderTokens` to type `CustomerCreatePasswordResetToken` - added property `customerGroupAssignments` to type `CustomerDraft` - added property `invalidateOlderTokens` to type `CustomerToken` +- added property `minCartQuantity` to type `InventoryEntry` +- added property `maxCartQuantity` to type `InventoryEntry` +- added property `minCartQuantity` to type `InventoryEntryDraft` +- added property `maxCartQuantity` to type `InventoryEntryDraft` - added property `recurrenceInfo` to type `MyLineItemDraft` - added property `recurrenceInfo` to type `MyCartAddLineItemAction` - added property `value` to type `CustomerEmailTokenCreatedMessage` @@ -169,6 +173,7 @@ - added type `ImportUnresolvedEventData` - added type `ImportValidationFailedEventData` - added type `ImportWaitForMasterVariantEventData` +- added type `InventoryEntrySetInventoryLimitsAction` - added type `MyCartSetCustomLineItemRecurrenceInfoAction` - added type `MyCartSetLineItemRecurrenceInfoAction` - added type `MyPaymentSetMethodInfoCustomFieldAction` diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index 63cb321010c..975fa825d35 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -6995,8 +6995,13 @@ $request = $builder ``` ## `withProjectKey("projectKey")->inventory()->post(null)` +Creates an InventoryEntry in the Project. + +If quantity limits are provided, existing Line Items that reference a Product Variant with an SKU that matches the Inventory Entry can be affected. For more information, see [Quantity limits](/../api/carts-orders-overview#quantity-limits). + Produces the [InventoryEntryCreated](ctp:api:type:InventoryEntryCreatedMessage) Message. + ### Example ```php use Commercetools\Api\Client\ApiRequestBuilder; diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntry.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntry.php index a975e852191..2710a33096c 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntry.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntry.php @@ -26,6 +26,8 @@ interface InventoryEntry extends BaseResource public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; public const FIELD_QUANTITY_ON_STOCK = 'quantityOnStock'; public const FIELD_AVAILABLE_QUANTITY = 'availableQuantity'; + public const FIELD_MIN_CART_QUANTITY = 'minCartQuantity'; + public const FIELD_MAX_CART_QUANTITY = 'maxCartQuantity'; public const FIELD_RESTOCKABLE_IN_DAYS = 'restockableInDays'; public const FIELD_EXPECTED_DELIVERY = 'expectedDelivery'; public const FIELD_CUSTOM = 'custom'; @@ -118,6 +120,22 @@ public function getQuantityOnStock(); */ public function getAvailableQuantity(); + /** + *
Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMinCartQuantity(); + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMaxCartQuantity(); + /** *How often the InventoryEntry is restocked (in days).
* @@ -197,6 +215,16 @@ public function setQuantityOnStock(?int $quantityOnStock): void; */ public function setAvailableQuantity(?int $availableQuantity): void; + /** + * @param ?int $minCartQuantity + */ + public function setMinCartQuantity(?int $minCartQuantity): void; + + /** + * @param ?int $maxCartQuantity + */ + public function setMaxCartQuantity(?int $maxCartQuantity): void; + /** * @param ?int $restockableInDays */ diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntryBuilder.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntryBuilder.php index 5d657a56768..761e8d45360 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntryBuilder.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntryBuilder.php @@ -97,6 +97,18 @@ final class InventoryEntryBuilder implements Builder */ private $availableQuantity; + /** + + * @var ?int + */ + private $minCartQuantity; + + /** + + * @var ?int + */ + private $maxCartQuantity; + /** * @var ?int @@ -236,6 +248,28 @@ public function getAvailableQuantity() return $this->availableQuantity; } + /** + *Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMinCartQuantity() + { + return $this->minCartQuantity; + } + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMaxCartQuantity() + { + return $this->maxCartQuantity; + } + /** *How often the InventoryEntry is restocked (in days).
* @@ -390,6 +424,28 @@ public function withAvailableQuantity(?int $availableQuantity) return $this; } + /** + * @param ?int $minCartQuantity + * @return $this + */ + public function withMinCartQuantity(?int $minCartQuantity) + { + $this->minCartQuantity = $minCartQuantity; + + return $this; + } + + /** + * @param ?int $maxCartQuantity + * @return $this + */ + public function withMaxCartQuantity(?int $maxCartQuantity) + { + $this->maxCartQuantity = $maxCartQuantity; + + return $this; + } + /** * @param ?int $restockableInDays * @return $this @@ -481,6 +537,8 @@ public function build(): InventoryEntry $this->supplyChannel instanceof ChannelReferenceBuilder ? $this->supplyChannel->build() : $this->supplyChannel, $this->quantityOnStock, $this->availableQuantity, + $this->minCartQuantity, + $this->maxCartQuantity, $this->restockableInDays, $this->expectedDelivery, $this->custom instanceof CustomFieldsBuilder ? $this->custom->build() : $this->custom diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraft.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraft.php index 7624da6ee7a..2fc3e8e7b7e 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraft.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraft.php @@ -20,6 +20,8 @@ interface InventoryEntryDraft extends JsonObject public const FIELD_KEY = 'key'; public const FIELD_SUPPLY_CHANNEL = 'supplyChannel'; public const FIELD_QUANTITY_ON_STOCK = 'quantityOnStock'; + public const FIELD_MIN_CART_QUANTITY = 'minCartQuantity'; + public const FIELD_MAX_CART_QUANTITY = 'maxCartQuantity'; public const FIELD_RESTOCKABLE_IN_DAYS = 'restockableInDays'; public const FIELD_EXPECTED_DELIVERY = 'expectedDelivery'; public const FIELD_CUSTOM = 'custom'; @@ -57,6 +59,22 @@ public function getSupplyChannel(); */ public function getQuantityOnStock(); + /** + *Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMinCartQuantity(); + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMaxCartQuantity(); + /** *How often the InventoryEntry is restocked (in days).
* @@ -101,6 +119,16 @@ public function setSupplyChannel(?ChannelResourceIdentifier $supplyChannel): voi */ public function setQuantityOnStock(?int $quantityOnStock): void; + /** + * @param ?int $minCartQuantity + */ + public function setMinCartQuantity(?int $minCartQuantity): void; + + /** + * @param ?int $maxCartQuantity + */ + public function setMaxCartQuantity(?int $maxCartQuantity): void; + /** * @param ?int $restockableInDays */ diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftBuilder.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftBuilder.php index d45a5454eb7..06e231cc14d 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftBuilder.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftBuilder.php @@ -49,6 +49,18 @@ final class InventoryEntryDraftBuilder implements Builder */ private $quantityOnStock; + /** + + * @var ?int + */ + private $minCartQuantity; + + /** + + * @var ?int + */ + private $maxCartQuantity; + /** * @var ?int @@ -112,6 +124,28 @@ public function getQuantityOnStock() return $this->quantityOnStock; } + /** + *Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMinCartQuantity() + { + return $this->minCartQuantity; + } + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + + * @return null|int + */ + public function getMaxCartQuantity() + { + return $this->maxCartQuantity; + } + /** *How often the InventoryEntry is restocked (in days).
* @@ -189,6 +223,28 @@ public function withQuantityOnStock(?int $quantityOnStock) return $this; } + /** + * @param ?int $minCartQuantity + * @return $this + */ + public function withMinCartQuantity(?int $minCartQuantity) + { + $this->minCartQuantity = $minCartQuantity; + + return $this; + } + + /** + * @param ?int $maxCartQuantity + * @return $this + */ + public function withMaxCartQuantity(?int $maxCartQuantity) + { + $this->maxCartQuantity = $maxCartQuantity; + + return $this; + } + /** * @param ?int $restockableInDays * @return $this @@ -251,6 +307,8 @@ public function build(): InventoryEntryDraft $this->key, $this->supplyChannel instanceof ChannelResourceIdentifierBuilder ? $this->supplyChannel->build() : $this->supplyChannel, $this->quantityOnStock, + $this->minCartQuantity, + $this->maxCartQuantity, $this->restockableInDays, $this->expectedDelivery, $this->custom instanceof CustomFieldsDraftBuilder ? $this->custom->build() : $this->custom diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftModel.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftModel.php index 51cd6f0b095..5c0c7b47341 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftModel.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntryDraftModel.php @@ -48,6 +48,18 @@ final class InventoryEntryDraftModel extends JsonObjectModel implements Inventor */ protected $quantityOnStock; + /** + * + * @var ?int + */ + protected $minCartQuantity; + + /** + * + * @var ?int + */ + protected $maxCartQuantity; + /** * * @var ?int @@ -75,6 +87,8 @@ public function __construct( ?string $key = null, ?ChannelResourceIdentifier $supplyChannel = null, ?int $quantityOnStock = null, + ?int $minCartQuantity = null, + ?int $maxCartQuantity = null, ?int $restockableInDays = null, ?DateTimeImmutable $expectedDelivery = null, ?CustomFieldsDraft $custom = null @@ -83,6 +97,8 @@ public function __construct( $this->key = $key; $this->supplyChannel = $supplyChannel; $this->quantityOnStock = $quantityOnStock; + $this->minCartQuantity = $minCartQuantity; + $this->maxCartQuantity = $maxCartQuantity; $this->restockableInDays = $restockableInDays; $this->expectedDelivery = $expectedDelivery; $this->custom = $custom; @@ -170,6 +186,46 @@ public function getQuantityOnStock() return $this->quantityOnStock; } + /** + *Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + * + * @return null|int + */ + public function getMinCartQuantity() + { + if (is_null($this->minCartQuantity)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_MIN_CART_QUANTITY); + if (is_null($data)) { + return null; + } + $this->minCartQuantity = (int) $data; + } + + return $this->minCartQuantity; + } + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + * + * @return null|int + */ + public function getMaxCartQuantity() + { + if (is_null($this->maxCartQuantity)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_MAX_CART_QUANTITY); + if (is_null($data)) { + return null; + } + $this->maxCartQuantity = (int) $data; + } + + return $this->maxCartQuantity; + } + /** *How often the InventoryEntry is restocked (in days).
* @@ -268,6 +324,22 @@ public function setQuantityOnStock(?int $quantityOnStock): void $this->quantityOnStock = $quantityOnStock; } + /** + * @param ?int $minCartQuantity + */ + public function setMinCartQuantity(?int $minCartQuantity): void + { + $this->minCartQuantity = $minCartQuantity; + } + + /** + * @param ?int $maxCartQuantity + */ + public function setMaxCartQuantity(?int $maxCartQuantity): void + { + $this->maxCartQuantity = $maxCartQuantity; + } + /** * @param ?int $restockableInDays */ diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntryModel.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntryModel.php index fe0d8eb97d2..7f13c94cfcb 100644 --- a/lib/commercetools-api/src/Models/Inventory/InventoryEntryModel.php +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntryModel.php @@ -96,6 +96,18 @@ final class InventoryEntryModel extends JsonObjectModel implements InventoryEntr */ protected $availableQuantity; + /** + * + * @var ?int + */ + protected $minCartQuantity; + + /** + * + * @var ?int + */ + protected $maxCartQuantity; + /** * * @var ?int @@ -130,6 +142,8 @@ public function __construct( ?ChannelReference $supplyChannel = null, ?int $quantityOnStock = null, ?int $availableQuantity = null, + ?int $minCartQuantity = null, + ?int $maxCartQuantity = null, ?int $restockableInDays = null, ?DateTimeImmutable $expectedDelivery = null, ?CustomFields $custom = null @@ -145,6 +159,8 @@ public function __construct( $this->supplyChannel = $supplyChannel; $this->quantityOnStock = $quantityOnStock; $this->availableQuantity = $availableQuantity; + $this->minCartQuantity = $minCartQuantity; + $this->maxCartQuantity = $maxCartQuantity; $this->restockableInDays = $restockableInDays; $this->expectedDelivery = $expectedDelivery; $this->custom = $custom; @@ -381,6 +397,46 @@ public function getAvailableQuantity() return $this->availableQuantity; } + /** + *Minimum quantity that can be added to a Cart. See Quantity limits.
+ * + * + * @return null|int + */ + public function getMinCartQuantity() + { + if (is_null($this->minCartQuantity)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_MIN_CART_QUANTITY); + if (is_null($data)) { + return null; + } + $this->minCartQuantity = (int) $data; + } + + return $this->minCartQuantity; + } + + /** + *Maximum quantity that can be added to a Cart. See Quantity limits.
+ * + * + * @return null|int + */ + public function getMaxCartQuantity() + { + if (is_null($this->maxCartQuantity)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_MAX_CART_QUANTITY); + if (is_null($data)) { + return null; + } + $this->maxCartQuantity = (int) $data; + } + + return $this->maxCartQuantity; + } + /** *How often the InventoryEntry is restocked (in days).
* @@ -535,6 +591,22 @@ public function setAvailableQuantity(?int $availableQuantity): void $this->availableQuantity = $availableQuantity; } + /** + * @param ?int $minCartQuantity + */ + public function setMinCartQuantity(?int $minCartQuantity): void + { + $this->minCartQuantity = $minCartQuantity; + } + + /** + * @param ?int $maxCartQuantity + */ + public function setMaxCartQuantity(?int $maxCartQuantity): void + { + $this->maxCartQuantity = $maxCartQuantity; + } + /** * @param ?int $restockableInDays */ diff --git a/lib/commercetools-api/src/Models/Inventory/InventoryEntrySetInventoryLimitsAction.php b/lib/commercetools-api/src/Models/Inventory/InventoryEntrySetInventoryLimitsAction.php new file mode 100644 index 00000000000..ff99ad8174a --- /dev/null +++ b/lib/commercetools-api/src/Models/Inventory/InventoryEntrySetInventoryLimitsAction.php @@ -0,0 +1,46 @@ +Sets the minimum quantity that can be added to a Cart. If the value is absent ornull
+ * the inventory limit is removed.
+ *
+
+ * @return null|int
+ */
+ public function getMinCartQuantity();
+
+ /**
+ * Sets the maximum quantity that can be added to a Cart. If the value is absent or null
+ * the inventory limit is removed.
Sets the minimum quantity that can be added to a Cart. If the value is absent or null
+ * the inventory limit is removed.
Sets the maximum quantity that can be added to a Cart. If the value is absent or null
+ * the inventory limit is removed.
Sets the minimum quantity that can be added to a Cart. If the value is absent or null
+ * the inventory limit is removed.
Sets the maximum quantity that can be added to a Cart. If the value is absent or null
+ * the inventory limit is removed.