getWishlistItems
Retrieves wishlist items from a specific wishlist or the first/default wishlist.
sdk.wishlists.methods.getWishlistItems()getWishlistItems(wishlistId?: number): Promise<ErrorResult | SuccessResult<WishlistItemSdkDto[]>>Parameters
wishlistId?number- (Optional) ID of the wishlist. If not provided, items from the first/default wishlist are returned.
Returns
Promise<ErrorResult | SuccessResult<WishlistItemSdkDto[]>>Promise that resolves to a success result with an array of wishlist items or rejects with an error
Usage example
Ensure the SDK and the WishlistsSdk module are ready:
function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.WISHLISTS;
window.gw.sdk.runIfModuleReady(moduleName, () => {
// Get items from a specific wishlist
window.gw.sdk.wishlists.methods.getWishlistItems(123)
.then((response) => {
console.log('Items:', response.result);
})
.catch(console.error);
// Get items from the first/default wishlist
window.gw.sdk.wishlists.methods.getWishlistItems()
.then((response) => {
console.log('Items:', response.result);
})
.catch(console.error);
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}