> 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 # IncrementAvailability # Package: catalogs # Namespace: InventorySpi # Method link: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/catalogs/inventory-service-plugin/increment-availability.md ## Introduction Increases the available stock quantity for specified items. Use this method when inventory needs to be incremented due to order events such as order cancellation, refund, or order editing. This method does not validate stock levels and allows negative inventory to be corrected. --- ## REST API ### Schema ``` Method: incrementAvailability Description: Increases the available stock quantity for specified items. Use this method when inventory needs to be incremented due to order events such as order cancellation, refund, or order editing. This method does not validate stock levels and allows negative inventory to be corrected. URL: null Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: items, items.catalogReference, items.catalogReference.catalogItemId, items.catalogReference.appId, items.quantity, items.subscriptionItem, orderId, reason Method parameters: param name: items | type: array | description: Items for which to increase their available stock quantity. | required: true - name: catalogReference | type: CatalogReference | description: Catalog reference that uniquely identifies the item. Contains the app GUID and catalog item GUID required to locate the specific item in the catalog. | required: true - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. | required: true - name: appId | type: string | description: GUID of the app providing the catalog. You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/). For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` | required: true - name: options | type: object | description: Additional item details in `key:value` pairs. Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items. For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md). - name: locationId | type: string | description: Location GUID where the inventory is managed. When not provided, the default location is used for inventory tracking. - name: quantity | type: integer | description: Quantity of the item to increment or decrement. For example, `5` to reduce availability by 5 units or increase availability by 5 units. | required: true - name: subscriptionItem | type: boolean | description: Whether the item is part of a subscription order. Subscription items may be processed differently by inventory systems depending on their recurring nature. | required: true param name: orderId | type: orderId | description: Order GUID associated with this inventory change. | required: true param name: reason | type: Reason | required: true - enum: ORDER_PLACED - Order was placed by a customer. ORDER_PAID - Order was paid for by a customer. ORDER_CANCELED - Order was canceled. ORDER_REFUNDED - Order was refunded. ORDER_EDITED - Order was edited by a merchant. ORDER_REJECTED - Order was rejected. Return type: IncrementAvailabilityResponse EMPTY-OBJECT {} Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INCREMENT_NOT_POSSIBLE | Description: Cannot increment availability due to invalid request parameters. ``` ### Examples ### Increment inventory by 4 units ```curl curl -X POST https://provider.example.com/v1/increment \ -H 'user-agent: Wix' \ -H 'accept-encoding: gzip, deflate' \ -H 'content-type: text/plain; charset=utf-8' \ -d '{ "items": [ { "catalogReference": { "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", "catalogItemId": "e35409da-d374-4c4b-b08b-6c703c5b6960" }, "locationId": "2163c198-6c85-4d30-b317-48714f627e4b", "quantity": 4, "subscriptionItem": false } ], "orderId": "a22ebad0-11ef-4a4d-a567-691fa7cb264c", "reason": "ORDER_EDITED" }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogs.InventorySpi.incrementAvailability(request, metadata) Description: Increases the available stock quantity for specified items. Use this method when inventory needs to be incremented due to order events such as order cancellation, refund, or order editing. This method does not validate stock levels and allows negative inventory to be corrected. Method parameters: param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature. Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ``` - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs. - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: languages | type: array | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. - name: instanceId | type: string | description: The service provider app's instance GUID. param name: request | type: IncrementAvailabilityRequest - name: items | type: array | description: Items for which to increase their available stock quantity. - name: catalogReference | type: CatalogReference | description: Catalog reference that uniquely identifies the item. Contains the app GUID and catalog item GUID required to locate the specific item in the catalog. - name: catalogItemId | type: string | description: GUID of the item within the catalog it belongs to. - name: appId | type: string | description: GUID of the app providing the catalog. You can get your app's GUID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/). For items from Wix catalogs, the following values always apply: + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` - name: options | type: object | description: Additional item details in `key:value` pairs. Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items. For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration.md) or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration.md), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction.md). - name: locationId | type: string | description: Location GUID where the inventory is managed. When not provided, the default location is used for inventory tracking. - name: quantity | type: integer | description: Quantity of the item to increment or decrement. For example, `5` to reduce availability by 5 units or increase availability by 5 units. - name: subscriptionItem | type: boolean | description: Whether the item is part of a subscription order. Subscription items may be processed differently by inventory systems depending on their recurring nature. - name: orderId | type: string | description: Order GUID associated with this inventory change. - name: reason | type: Reason | description: Reason for the inventory increment. - enum: - ORDER_PLACED: Order was placed by a customer. - ORDER_PAID: Order was paid for by a customer. - ORDER_CANCELED: Order was canceled. - ORDER_REFUNDED: Order was refunded. - ORDER_EDITED: Order was edited by a merchant. - ORDER_REJECTED: Order was rejected. Return type: PROMISE EMPTY-OBJECT {} Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: INCREMENT_NOT_POSSIBLE | Description: Cannot increment availability due to invalid request parameters. ``` ### Examples ### Basic inventory increment for order cancellation or refund Increments inventory when an order is canceled or refunded, restoring stock levels ```javascript import { inventory } from "@wix/ecom/service-plugins"; inventory.provideHandlers({ incrementAvailability: async (payload) => { const { request, metadata } = payload; // Use the `request` and `metadata` received from Wix and // apply custom logic. // Example: Log the increment operation console.log(`Incrementing inventory for order: ${request.orderId}`); // Example: Add custom logic based on reason switch (request.reason) { case "ORDER_CANCELED": console.log('Restoring inventory due to order cancellation'); break; case "ORDER_REFUNDED": console.log('Restoring inventory due to order refund'); break; case "ORDER_EDITED": console.log('Adjusting inventory due to order modification'); break; default: console.log(`Processing increment for reason: ${request.reason}`); } // Example: Handle subscription items differently const hasSubscriptionItems = request.items.some(item => item.subscriptionItem); if (hasSubscriptionItems) { console.log('Processing subscription items with special handling'); } // Return your response exactly as documented to integrate with Wix. return { // Empty response indicates successful increment }; } }); ``` ### incrementAvailability (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 { inventory } from '@wix/ecom/service-plugins'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { inventory }, // Include the auth strategy and host as relevant }); async function incrementAvailability(request,metadata) { const response = await myWixClient.inventory.incrementAvailability(request,metadata); }; ``` ---