> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # BulkDecrementInventoryItemsByVariantAndLocation # Package: catalogV3 # Namespace: InventoryService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/inventory-items-v3/bulk-decrement-inventory-items-by-variant-and-location.md ## Permission Scopes: Inventory write in v3 catalog: SCOPE.STORES.INVENTORY_ITEM_WRITE ## Introduction Decrements quantities of multiple inventory items by variant and location. > **Notes:**: > + `trackQuantity` must be `true` to allow for decrementing the quantity. > + If you pass `restrictInventory: true` and the `decrementData.decrementBy` amount is greater than the current quantity in stock, the request will fail with an `INSUFFICIENT_INVENTORY` error. > + Pass `restrictInventory: false` to allow for negative quantities. > + If you pass `preorderRequest: true` and the item is available for preorder, the item's `preorderCounter` will increase and the item's quantity will stay the same. --- ## REST API ### Schema ``` Method: bulkDecrementInventoryItemsByVariantAndLocation Description: Decrements quantities of multiple inventory items by variant and location. > **Notes:**: > + `trackQuantity` must be `true` to allow for decrementing the quantity. > + If you pass `restrictInventory: true` and the `decrementData.decrementBy` amount is greater than the current quantity in stock, the request will fail with an `INSUFFICIENT_INVENTORY` error. > + Pass `restrictInventory: false` to allow for negative quantities. > + If you pass `preorderRequest: true` and the item is available for preorder, the item's `preorderCounter` will increase and the item's quantity will stay the same. URL: https://www.wixapis.com/stores/v3/bulk/inventory-items/decrement-by-variant-and-location Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: decrementData, decrementData.variantId, decrementData.decrementBy Method parameters: param name: decrementData | type: array | description: Variant and location GUIDs, as well as decrement data. | required: true - name: variantId | type: string | description: Variant GUID. | required: true - name: locationId | type: string | description: Location GUID. - name: decrementBy | type: integer | description: Amount to decrement by. | required: true - name: preorderRequest | type: boolean | description: Whether the request to decrement the inventory item's quantity was made as part of a purchase that includes preorder items. + If `true` and the item is available for preorder in the default location, negative inventory quantity is allowed. + If `false` and the item is not available for preorder, negative inventory is not allowed. param name: reason | type: ReasonType | description: The reason for the inventory change. - enum: ORDER - MANUAL - REVERT_INVENTORY_CHANGE - param name: restrictInventory | type: restrictInventory | description: Whether to allow negative inventory following this decrement action. Default: `false` (negative inventory is not allowed) param name: returnEntity | type: returnEntity | description: Whether to return the full inventory item entities in the response. Default: `false` Return type: BulkDecrementInventoryItemsByVariantAndLocationResponse - name: results | type: array | description: Inventory items updated by bulk action. - name: itemMetadata | type: ItemMetadata | description: Bulk action metadata for inventory item. - name: id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item). - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items. - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated. - name: error | type: ApplicationError | description: Details about the error in case of failure. - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: item | type: InventoryItem | description: Full inventory item entity. Returned only if `returnEntity: true` is passed in the request. - ONE-OF: - name: inStock | type: boolean | description: Indicates that inventory is tracked by status rather than quantity. When set to `true`, the item is marked as available for sale without tracking exact quantities. When set to `false`, the item is marked as out of stock. This tracking method is useful for made-to-order products or items with unlimited inventory. When using this tracking method, `trackQuantity` is `false` and preorder limits aren't supported. - name: quantity | type: integer | description: Indicates that inventory is tracked by quantity. Set this field to the number of items currently in stock. This tracking method is useful when you need to know exactly how many items are available. When using this tracking method, `trackQuantity` is `true`. Quantity can be negative when inventory is decremented for an order that has already been paid. - name: id | type: string | description: Inventory item GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the inventory item is updated. To prevent conflicting changes, the current revision must be passed when updating the inventory item. Ignored when creating an inventory item. - name: createdDate | type: string | description: Date and time the inventory item was created. - name: updatedDate | type: string | description: Date and time the inventory item was last updated. - name: variantId | type: string | description: Variant GUID. - name: locationId | type: string | description: Stores location GUID. If not specified when creating an inventory item, the store's default location is used. - name: productId | type: string | description: Product GUID. - name: trackQuantity | type: boolean | description: Whether the quantity is being tracked. - name: availabilityStatus | type: AvailabilityStatus | description: Inventory item availability status. - enum: - OUT_OF_STOCK: Item is out of stock. For tracked inventory, `quantity` is zero or negative and preorder isn't available. - IN_STOCK: Item is in stock and available for purchase. For tracked inventory, see the `quantity` field for the exact amount in stock. - PREORDER: Item is available for preorder only. Stock is zero or negative, but preorder is enabled with remaining capacity. - name: preorderInfo | type: PreorderInfo | description: Item preorder info. Preorder settings are configured per inventory item, so each variant-location combination can have its own preorder configuration. > **Note:** The product entity's `inventory.preorderStatus` and `inventory.preorderAvailability` fields reflect only the default location's preorder state. - name: enabled | type: boolean | description: Whether preorder is enabled for this inventory item. > **Note:** Preorder can't be enabled for digital products or products with subscriptions. Default: `false` - name: message | type: string | description: Message displayed to customers when the item is out of stock and preorder is enabled. - name: limit | type: integer | description: Maximum number of items that can be preordered after stock reaches zero. Supported only for inventory items with `trackQuantity = true`. Default: `100000` - name: counter | type: integer | description: Number of times this item has been preordered. Supported only for inventory items with `trackQuantity = true`. - name: quantity | type: integer | description: Remaining quantity available for preorder. Supported only for items with `trackQuantity` set to `true`. - name: product | type: Product | description: Associated product and variant details. - name: name | type: string | description: Product name. - name: directCategoryIds | type: array | description: List of category GUIDs that this product is included in directly. - name: variantName | type: string | description: Variant name. - name: variantSku | type: string | description: Variant SKU (stock keeping unit). - name: variantVisible | type: boolean | description: Whether the variant is visible in the store. - name: extendedFields | type: ExtendedFields | description: Custom field data for the inventory item object. [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. - name: totalSuccesses | type: integer | description: Number of items that were successfully processed. - name: totalFailures | type: integer | description: Number of items that couldn't be processed. - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_FOUND | Description: Inventory item with the specified `variant_id` and `location_id` not found. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MIN_QUANTITY_LIMIT_REACHED | Description: Decrement would reduce inventory below minimum quantity limit or `preorderInfo.counter` would exceed its maximum value. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: Decrement would result in negative `quantity` or exceed preorder limit. Set `restrict_inventory` to `false` to allow negative quantities. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVENTORY_QUANTITY_NOT_TRACKED | Description: Decrement attempted for untracked inventory. Enable inventory tracking first. ``` ### Examples ### Decrement quantity of multiple inventory items by variant ID and location ID Decrement quantity of multiple inventory items. The 1st item is requested with both variant ID and location ID of a tracked inventory item. The 2nd is requested with variant ID and empty location ID, so the variant in the default location is updated. The 3rd is requested with variant ID and location ID to be decremented as a preorder. ```curl curl -X POST \ 'https://www.wixapis.com/stores/v3/bulk/inventory-items/decrement-by-variant-and-location' \ -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "decrementData": [ { "variantId": "4d9126f7-6fcb-423a-89df-bd5e61b83b01", "locationId": "b6e63540-242c-462a-ac6c-b1e449e0c194", "decrementBy": 1 }, { "variantId": "666795f6-15dd-4f99-806e-129dd834f1ac", "decrementBy": 3 }, { "variantId": "ccfda17f-b124-4044-af19-069da8a83c25", "preorderRequest": true, "locationId": "10300abc-8f76-49a0-bf89-d5219a1418fa", "decrementBy": 2 } ], "returnEntity": true, "restrictInventory": true, "reason": "ORDER" }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogV3.InventoryService.bulkDecrementInventoryItemsByVariantAndLocation(decrementData, options) Description: Decrements quantities of multiple inventory items by variant and location. > **Notes:**: > + `trackQuantity` must be `true` to allow for decrementing the quantity. > + If you pass `restrictInventory: true` and the `decrementData.decrementBy` amount is greater than the current quantity in stock, the request will fail with an `INSUFFICIENT_INVENTORY` error. > + Pass `restrictInventory: false` to allow for negative quantities. > + If you pass `preorderRequest: true` and the item is available for preorder, the item's `preorderCounter` will increase and the item's quantity will stay the same. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: decrementData, decrementData.variantId, decrementData.decrementBy Method parameters: param name: decrementData | type: array | description: Variant and location GUIDs, as well as decrement data. | required: true - name: variantId | type: string | description: Variant GUID. | required: true - name: locationId | type: string | description: Location GUID. - name: decrementBy | type: integer | description: Amount to decrement by. | required: true - name: preorderRequest | type: boolean | description: Whether the request to decrement the inventory item's quantity was made as part of a purchase that includes preorder items. + If `true` and the item is available for preorder in the default location, negative inventory quantity is allowed. + If `false` and the item is not available for preorder, negative inventory is not allowed. param name: options | type: BulkDecrementInventoryItemsByVariantAndLocationOptions none - name: restrictInventory | type: boolean | description: Whether to allow negative inventory following this decrement action. Default: `false` (negative inventory is not allowed) - name: returnEntity | type: boolean | description: Whether to return the full inventory item entities in the response. Default: `false` - name: reason | type: ReasonType | description: Reason for decrement inventory action. - enum: ORDER, MANUAL, REVERT_INVENTORY_CHANGE Return type: PROMISE - name: results | type: array | description: Inventory items updated by bulk action. - name: itemMetadata | type: ItemMetadata | description: Bulk action metadata for inventory item. - name: _id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item). - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items. - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated. - name: error | type: ApplicationError | description: Details about the error in case of failure. - name: code | type: string | description: Error code. - name: description | type: string | description: Description of the error. - name: data | type: object | description: Data related to the error. - name: item | type: InventoryItem | description: Full inventory item entity. Returned only if `returnEntity: true` is passed in the request. - ONE-OF: - name: inStock | type: boolean | description: Indicates that inventory is tracked by status rather than quantity. When set to `true`, the item is marked as available for sale without tracking exact quantities. When set to `false`, the item is marked as out of stock. This tracking method is useful for made-to-order products or items with unlimited inventory. When using this tracking method, `trackQuantity` is `false` and preorder limits aren't supported. - name: quantity | type: integer | description: Indicates that inventory is tracked by quantity. Set this field to the number of items currently in stock. This tracking method is useful when you need to know exactly how many items are available. When using this tracking method, `trackQuantity` is `true`. Quantity can be negative when inventory is decremented for an order that has already been paid. - name: _id | type: string | description: Inventory item GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the inventory item is updated. To prevent conflicting changes, the current revision must be passed when updating the inventory item. Ignored when creating an inventory item. - name: _createdDate | type: Date | description: Date and time the inventory item was created. - name: _updatedDate | type: Date | description: Date and time the inventory item was last updated. - name: variantId | type: string | description: Variant GUID. - name: locationId | type: string | description: Stores location GUID. If not specified when creating an inventory item, the store's default location is used. - name: productId | type: string | description: Product GUID. - name: trackQuantity | type: boolean | description: Whether the quantity is being tracked. - name: availabilityStatus | type: AvailabilityStatus | description: Inventory item availability status. - enum: - OUT_OF_STOCK: Item is out of stock. For tracked inventory, `quantity` is zero or negative and preorder isn't available. - IN_STOCK: Item is in stock and available for purchase. For tracked inventory, see the `quantity` field for the exact amount in stock. - PREORDER: Item is available for preorder only. Stock is zero or negative, but preorder is enabled with remaining capacity. - name: preorderInfo | type: PreorderInfo | description: Item preorder info. Preorder settings are configured per inventory item, so each variant-location combination can have its own preorder configuration. > **Note:** The product entity's `inventory.preorderStatus` and `inventory.preorderAvailability` fields reflect only the default location's preorder state. - name: enabled | type: boolean | description: Whether preorder is enabled for this inventory item. > **Note:** Preorder can't be enabled for digital products or products with subscriptions. Default: `false` - name: message | type: string | description: Message displayed to customers when the item is out of stock and preorder is enabled. - name: limit | type: integer | description: Maximum number of items that can be preordered after stock reaches zero. Supported only for inventory items with `trackQuantity = true`. Default: `100000` - name: counter | type: integer | description: Number of times this item has been preordered. Supported only for inventory items with `trackQuantity = true`. - name: quantity | type: integer | description: Remaining quantity available for preorder. Supported only for items with `trackQuantity` set to `true`. - name: product | type: Product | description: Associated product and variant details. - name: name | type: string | description: Product name. - name: directCategoryIds | type: array | description: List of category GUIDs that this product is included in directly. - name: variantName | type: string | description: Variant name. - name: variantSku | type: string | description: Variant SKU (stock keeping unit). - name: variantVisible | type: boolean | description: Whether the variant is visible in the store. - name: extendedFields | type: ExtendedFields | description: Custom field data for the inventory item object. [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata. - name: totalSuccesses | type: integer | description: Number of items that were successfully processed. - name: totalFailures | type: integer | description: Number of items that couldn't be processed. - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_FOUND | Description: Inventory item with the specified `variant_id` and `location_id` not found. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: MIN_QUANTITY_LIMIT_REACHED | Description: Decrement would reduce inventory below minimum quantity limit or `preorderInfo.counter` would exceed its maximum value. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INSUFFICIENT_INVENTORY | Description: Decrement would result in negative `quantity` or exceed preorder limit. Set `restrict_inventory` to `false` to allow negative quantities. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INVENTORY_QUANTITY_NOT_TRACKED | Description: Decrement attempted for untracked inventory. Enable inventory tracking first. ``` ### Examples ### bulkDecrementInventoryItemsByVariantAndLocation ```javascript import { inventoryItemsV3 } from '@wix/stores'; async function bulkDecrementInventoryItemsByVariantAndLocation(decrementData,options) { const response = await inventoryItemsV3.bulkDecrementInventoryItemsByVariantAndLocation(decrementData,options); }; ``` ### bulkDecrementInventoryItemsByVariantAndLocation (with elevated permissions) ```javascript import { inventoryItemsV3 } from '@wix/stores'; import { auth } from '@wix/essentials'; async function myBulkDecrementInventoryItemsByVariantAndLocationMethod(decrementData,options) { const elevatedBulkDecrementInventoryItemsByVariantAndLocation = auth.elevate(inventoryItemsV3.bulkDecrementInventoryItemsByVariantAndLocation); const response = await elevatedBulkDecrementInventoryItemsByVariantAndLocation(decrementData,options); } ``` ### bulkDecrementInventoryItemsByVariantAndLocation (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { inventoryItemsV3 } from '@wix/stores'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { inventoryItemsV3 }, // Include the auth strategy and host as relevant }); async function bulkDecrementInventoryItemsByVariantAndLocation(decrementData,options) { const response = await myWixClient.inventoryItemsV3.bulkDecrementInventoryItemsByVariantAndLocation(decrementData,options); }; ``` ---