How to add “Add to cart” button functionality in wish list

Add data-action=”add-item-to-cart” in template file

_.extend(ProductListDetailsView.prototype, { 
						events: {
							'click [data-action="add-item-to-cart"]': 'addIndividualItemToCartBulkHandler',
                             
						},

					
						},

addIndividualItemToCartBulkHandler: function addIndividualItemToCartBulkHandler(e) {
                            e.preventDefault();
                            var self = this;
                           
                            var itemid = this.$(e.target).data('id');
                          
                            var array = self.model.get('items').models;
                           
                            var foundIndex = array.findIndex((el) => (el.id == itemid));
                         
                            var item = array[foundIndex]
                          
                            var add_to_cart_promise = this.cart.addProduct(item);

                            add_to_cart_promise.then(function () {
                                self.unselectAll();
                                self.showConfirmationHelper();
                            });

                            this.disableElementsOnPromise(add_to_cart_promise);


                        }
})

Leave a comment

Your email address will not be published. Required fields are marked *