incrementInventory( )


Adds a set number of items from inventory.

The incrementInventory() function returns a Promise that is resolved when the specified item's quantity has been updated in the inventory.

Method Declaration
Copy
function incrementInventory(items: Array<IncrementInfo>): Promise<void>;
Method Parameters
itemsArray<IncrementInfo>Required

Inventory items to increment.

Increment the inventory of a product's first variant
JavaScript
/******************************* * Backend code - inventory.jsw * *******************************/ import wixStoresBackend from "wix-stores-backend"; export function incrementInventory(incrementInfo) { return wixStoresBackend.incrementInventory(incrementInfo); } /************** * Page code * **************/ import { incrementInventory } from "backend/inventory"; async function incrementHandler() { const productId = "3fb6a3c8-988b-8755-04bd-ks75ae0b18ea"; let variants = await getProductVariants(productId); incrementInventory([ { variantId: variants[0]._id, productId: productId, incrementBy: 1, }, ]) .then(() => { console.log("Inventory incremented successfully"); }) .catch((error) => { // Inventory increment failed console.error(error); }); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?