addToCart function for a TextButton

Hi!
I created a Wishlist functionality but I want to add function AddToCart from my Wishlist.
And I cannot find the way to do it. When I’m trying to add BuyButton from the Store to Repeater - it doesn’t repeat.
What code should I use to my repeater item in container to make the TextButton addToCart?

Hi,
Check out this reference:

Ro.

Hi Roi!
Can you tell me where should I put this function? Because when I tried to put this
$w(‘#addToCart’).onClick(()=>{$w(‘#shoppingCartIcon1’).addToCart(product.id);});
It didn’t work

function myItemReady($w, wishlistItem){
let product = wishlistItem.product;
$w(‘#productImage’).src = product.mainMedia;
$w(‘#name’).text = product.name;
$w(‘#price’).text = product.formattedPrice;
$w(‘#productImage’).onClick(()=>{
wixLocation.to(product.productPageUrl);
});
$w(‘#addToCart’).onClick(()=>{$w(‘#shoppingCartIcon1’).addToCart(product.id);});
$w(‘#removeItem’).onClick(removeItem(wishlistItem._id));
}

function removeItem(id) {
return async function () {
await wixData.remove(‘wishlist’, id);
loadWishlist();
}
}

hi,
change to this

$w(‘#addToCartIcon’).onClick(()=>{$w(‘#shoppingCartIcon1’).addToCart(product._id);});

1 Like

Now it works! Thank you!

1 Like