Search...
decrementInventory( )
Subtracts a set number of items from inventory.
Description
The decrementInventory()
function returns a Promise that is resolved
when the specified item's quantity has been updated in the inventory.
Syntax
function decrementInventory(items: Array<DecrementInfo>): Promise<void>
decrementInventory Parameters
NAME
TYPE
DESCRIPTION
items
Array<DecrementInfo>
Inventory items to decrement.
Returns
Fulfilled - When the inventory is decremented.
Return Type:
Promise<void>
Related Content:
Was this helpful?
Decrement the inventory of a product's first variant
Code Example
1/*******************************2 * Backend code - inventory.jsw *3 *******************************/45import wixStoresBackend from 'wix-stores-backend';67export function decrementInventory(decrementInfo) {8 return wixStoresBackend.decrementInventory(decrementInfo);9}101112/**************13 * Page code *14 **************/1516import { decrementInventory } from 'backend/inventory';171819async function decrementHandler() {2021 const productId = "3fb6a3c8-988b-8755-04bd-ks75ae0b18ea"22 let variants = await getProductVariants(productId);2324 decrementInventory(25 [{26 variantId: variants[0]._id,27 productId: productId,28 decrementBy: 129 }])30 .then(() => {31 console.log("Inventory decremented successfully")32 })33 .catch(error => {34 // Inventory decrement failed35 console.error(error);36 })37}