Updates product inventory, including total quantity, whether the product is in stock, and whether the product inventory is tracked.
The updateInventoryVariants()
function is a Promise that resolves to the updated inventory variant data.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateInventoryVariants(
productId: string,
inventoryItem: UpdateInventoryVariantsInventoryItem,
options: UpdateInventoryVariantsOptions,
): Promise<void>;
Product ID.
Inventory item to update.
import { inventory } from "wix-stores.v2";
async function updateInventoryVariants(productId, inventoryItem, options) {
try {
const result = await inventory.updateInventoryVariants(
productId,
inventoryItem,
options,
);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.