Skip to main content

Wishlist item deleted

This event is triggered when an item is deleted from a wishlist. It provides details about the wishlist and the item that was removed.

Event details​

WishlistItemDeletedSdkEvent
event
Properties
readonly productIdnumber
ID of the product that was removed from the wishlist
readonly typeWISHLIST_ITEM_DELETED
Event type, which is "wishlistItemDeleted"
readonly variantIdnumber
ID of the product variant that was removed
readonly wishlistIdnumber
ID of the wishlist from which the item was deleted

Usage example​

Before listening for the wishlistItemDeleted event, ensure the SDK and the Wishlists module are ready:

function subscribeToWishlistItemDeleted() {
const wishlistItemDeletedEventType =
window.gw.sdk.wishlists.events.WISHLIST_ITEM_DELETED;

window.gw.sdk.on(wishlistItemDeletedEventType, (event) => {
console.log(event.detail);
});
}

function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.WISHLISTS;

window.gw.sdk.runIfModuleReady(moduleName, () => {
subscribeToWishlistItemDeleted();
});
}

if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}

// Example output:
// {type: 'wishlistItemDeleted', wishlistId: 123, productId: 456, variantId: 789}

This code ensures the SDK and the Wishlists module are ready before setting up the event listener, allowing you to respond when an item is deleted from a wishlist and access the relevant details.