createWishlist
Creates a new wishlist with the specified title.
sdk.wishlists.methods.createWishlist()createWishlist(title: string): Promise<ErrorResult | SuccessResult<WishlistSdkDto>>Parameters
titlestring- The title for the new wishlist
Returns
Promise<ErrorResult | SuccessResult<WishlistSdkDto>>Promise that resolves to a success result with the created wishlist 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, () => {
window.gw.sdk.wishlists.methods.createWishlist("My New Wishlist")
.then((response) => {
console.log('Created wishlist:', response.result);
})
.catch(console.error);
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}