An event that fires when variant information for a product is updated.
The onVariantsUpdated()
event handler runs when variant information for a product
is updated in a store.
Note: Backend events don't work when previewing your site.
function onVariantsUpdated(event: VariantsUpdatedEvent): void;
Information about the product collection that was deleted.
// Place this code in the events.js file
// of your site's Backend section.
export function wixStores_onVariantsUpdated(event) {
let productId = event.productId;
let firstVariant = event.variants[0];
}
/* Full event object:
*
* {
* "variants":[
* {
* "updatedFields":[
* "price"
* ],
* "choices":{
* "Color":"Red"
* },
* "variantId":"00000000-0000-0001-0005-970d993bafe9"
* }, {
* "updatedFields":[
* "sku"
* ],
* "choices":{
* "Color":"Blue"
* },
* "variantId":"00000000-0000-0002-0005-970d993bafe9"
* }
* ],
* "productId":"1a2d7e83-4bef-31d5-09e1-3326ee271c09"
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.