Hi i have been trying to achieve a function to remove product from wishlist page by clicking remove button but somehow I’m not able to do so. Here’s the code which I had tried can you help me out in this?
var Sunrise = {
removeItem(line, qty) {
console.log("Click")
fetch('/products/${handle}?view=card', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
quantity: qty,
line: line
})
}).then(function (response) {
return response.json();
}).then(function (data) {
// fire javascript event on window
document.dispatchEvent(new CustomEvent('shopify-wishlist:updated', {detail: data}));
})["catch"](function (error) {
console.error('Error:', error);
});
}
};
window.Sunrise = Sunrise;