> 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 # GetInventoryVariants # Package: catalogV1 # Namespace: InventoryReadApi # Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/inventory/get-inventory-variants.md ## Permission Scopes: Read Products: SCOPE.DC-STORES.READ-PRODUCTS ## Introduction ## Method Permissions: WIX_STORES.READ_INVENTORY --- ## REST API ### Schema ``` Method: getInventoryVariants Description: URL: https://www.wixapis.com/stores-reader/v2/inventoryItems/{inventoryId}/getVariants Method: POST Method parameters: - ONE-OF: - name: inventoryId | type: string | description: Inventory item GUID. - name: productId | type: string | description: Product GUID. param name: variantIds | type: array | description: Variant GUIDs to query for this inventory item (optional). Return type: GetInventoryVariantsResponse - name: inventoryItem | type: InventoryItemV2 | description: Inventory item. - name: id | type: string | description: Inventory item GUID. - name: productId | type: string | description: Product GUID. - name: trackQuantity | type: boolean | description: Whether quantity is being tracked. - name: variants | type: array | description: Variants associated with this inventory item. - name: variantId | type: string | description: Variant GUID. - name: inStock | type: boolean | description: Whether the product is listed as in stock. - name: quantity | type: integer | description: Quantity currently left in inventory. - name: availableForPreorder | type: boolean | description: Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level. - name: lastUpdated | type: string | description: Last updated timestamp. - name: numericId | type: number | description: Inventory’s unique numeric GUID (assigned in ascending order). Primarily for sorting and filtering when crawling all inventories. - name: preorderInfo | type: PreorderInfo | description: Preorder information. - name: enabled | type: boolean | description: Whether the item is available for preorder. - name: message | type: string | description: A message the buyer will see when the item is out of stock and preorder is enabled. - name: limit | type: integer | description: Number of products that can be preordered after stock reaches zero. ``` ### Examples ### GetInventoryVariants ```curl ~~~cURL curl -X POST https://www.wixapis.com/stores/v2/inventoryItems/be547028-fb08-b962-75e8-3f3e56da9ee3/getVariants \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-binary ' {} }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogV1.InventoryReadApi.getInventoryVariants(inventoryId, options) Description: # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: inventoryId Method parameters: param name: inventoryId | type: string | description: Inventory item GUID. | required: true param name: options | type: GetInventoryVariantsOptions none - ONE-OF: - name: inventoryId | type: string | description: Inventory item GUID. - name: productId | type: string | description: Product GUID. - name: variantIds | type: array | description: Variant GUIDs to query for this inventory item (optional). Return type: PROMISE - name: inventoryItem | type: InventoryItemV2 | description: Inventory item. - name: _id | type: string | description: Inventory item GUID. - name: productId | type: string | description: Product GUID. - name: trackQuantity | type: boolean | description: Whether quantity is being tracked. - name: variants | type: array | description: Variants associated with this inventory item. - name: variantId | type: string | description: Variant GUID. - name: inStock | type: boolean | description: Whether the product is listed as in stock. - name: quantity | type: integer | description: Quantity currently left in inventory. - name: availableForPreorder | type: boolean | description: Whether the variant is available for preorder. When `true`, the variant is out of stock and preorder is enabled on inventory level. - name: lastUpdated | type: Date | description: Last updated timestamp. - name: numericId | type: number | description: Inventory’s unique numeric GUID (assigned in ascending order). Primarily for sorting and filtering when crawling all inventories. - name: preorderInfo | type: PreorderInfo | description: Preorder information. - name: enabled | type: boolean | description: Whether the item is available for preorder. - name: message | type: string | description: A message the buyer will see when the item is out of stock and preorder is enabled. - name: limit | type: integer | description: Number of products that can be preordered after stock reaches zero. ``` ### Examples ### Get inventory variants Get inventory variants for a specific inventory item ```javascript import { inventory } from "@wix/stores"; const inventoryId = "3bc2c93a-3ca5-6e13-e3cc-2d71038f2a59"; async function getInventoryVariants() { const response = await inventory.getInventoryVariants(inventoryId); return response; } const result = await inventory.getInventoryVariants(inventoryId); /* Promise resolves to: * { * "inventoryItem": { * "externalId": "c43d36c5-c35a-91ec-1c33-d28efc70d5a6", * "productId": "c43d36c5-c35a-91ec-1c33-d28efc70d5a6", * "trackQuantity": true, * "variants": [ * { * "variantId": "00000000-0000-0000-0000-000000000000", * "inStock": true, * "quantity": 10, * "availableForPreorder": false * } * ], * "numericId": "1766909903931000", * "preorderInfo": { * "enabled": false * }, * "_id": "3bc2c93a-3ca5-6e13-e3cc-2d71038f2a59" * } * } */ ``` ### Get inventory variants Get inventory variants for a specific inventory item ```javascript import { inventory } from "@wix/stores"; const inventoryId = "3bc2c93a-3ca5-6e13-e3cc-2d71038f2a59"; async function getInventoryVariants() { const response = await inventory.getInventoryVariants(inventoryId); return response; } const result = await inventory.getInventoryVariants(inventoryId); /* Promise resolves to: * { * "inventoryItem": { * "externalId": "c43d36c5-c35a-91ec-1c33-d28efc70d5a6", * "productId": "c43d36c5-c35a-91ec-1c33-d28efc70d5a6", * "trackQuantity": true, * "variants": [ * { * "variantId": "00000000-0000-0000-0000-000000000000", * "inStock": true, * "quantity": 10, * "availableForPreorder": false * } * ], * "numericId": "1766909903931000", * "preorderInfo": { * "enabled": false * }, * "_id": "3bc2c93a-3ca5-6e13-e3cc-2d71038f2a59" * } * } */ ``` ### getInventoryVariants (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/stores'; // 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 getInventoryVariants(inventoryId,options) { const response = await myWixClient.inventory.getInventoryVariants(inventoryId,options); }; ``` ---