Search.../

incrementInventory( )

Adds a set number of items from inventory.

Description

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

Syntax

function incrementInventory(items: Array<IncrementInfo>): Promise<void>

incrementInventory Parameters

NAME
TYPE
DESCRIPTION
items

Array<IncrementInfo>

Inventory items to increment.

Returns

Fulfilled - When the inventory is incremented.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Increment the inventory of a product's first variant

Code Example

Copy Code
1/*******************************
2 * Backend code - inventory.jsw *
3 *******************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export function incrementInventory(incrementInfo) {
8 return wixStoresBackend.incrementInventory(incrementInfo);
9}
10
11
12/**************
13 * Page code *
14 **************/
15
16import { incrementInventory } from 'backend/inventory';
17
18
19async function incrementHandler() {
20
21 const productId = "3fb6a3c8-988b-8755-04bd-ks75ae0b18ea"
22 let variants = await getProductVariants(productId);
23
24 incrementInventory(
25 [{
26 variantId: variants[0]._id,
27 productId: productId,
28 incrementBy: 1
29 }])
30 .then(() => {
31 console.log("Inventory incremented successfully")
32 })
33 .catch(error => {
34 // Inventory increment failed
35 console.error(error);
36 })
37}