Search.../

updateInventoryVariants( )

Developer Preview

Updates product inventory, including total quantity, whether the product is in stock, and whether the product inventory is tracked.

Description

The updateInventoryVariants() function is a Promise that resolves to the updated inventory variant data.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function updateInventoryVariants(productId: string, inventoryItem: UpdateInventoryVariantsInventoryItem): Promise<void>

updateInventoryVariants Parameters

NAME
TYPE
DESCRIPTION
productId
string

Product ID.

inventoryItem
UpdateInventoryVariantsInventoryItem

Inventory item to update.

Returns

Return Type:

Promise<
void
>

Was this helpful?

updateInventoryVariants example

Copy Code
1import { inventory } from 'wix-stores.v2';
2
3 async function updateInventoryVariants(productId, inventoryItem, options) {
4 try {
5 const result = await inventory.updateInventoryVariants(productId, inventoryItem, options);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13