Search...
onInventoryVariantUpdated( )
An event that fires when the inventory information of a product variant is updated.
Description
The onInventoryVariantUpdated()
event handler runs when inventory information for a product
variant is updated in a store.
Note: Backend events don't work when previewing your site.
Syntax
function onInventoryVariantUpdated(event: InventoryVariantUpdatedEvent): void
onInventoryVariantUpdated Parameters
NAME
TYPE
DESCRIPTION
event
InventoryVariantUpdatedEvent
Information about the updated variant.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event when product variant inventory information is updated
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.34export function wixStores_onInventoryVariantUpdated(event) {5 let inventoryItemId = event.inventoryItemId;6 let firstVariant = event.variants[0];7 let firstNewQuantity = firstVariant.newValue.quantity;8}910/* Full event object:11 *12 * {13 * "variants": [14 * {15 * "oldValue": {16 * "inStock": true,17 * "quantity": 1018 * },19 * "newValue": {20 * "inStock": true,21 * "quantity": 5022 * },23 * "id": "00000000-0000-0000-0000-000000000000"24 * }25 * ],26 * "externalId": "8fe8f05f-951e-1563-b917-88adf8284543",27 * "inventoryItemId": "70170fa0-6ae1-ea9c-46e8-775207d7babc"28 * }29 *30 */