Hi forum! We are currently working on our product page (theproducerschool.com/packs) and we are using a custom repeater to showcase our products.
We have added the following code to let the buttons in the repeater function as an add to cart button:
$w.onReady( function () {
$w( “#addToCart” ).onClick((event) => {
let $item = $w.at(event.context);
let selectedProduct = $item( ‘#dataset4’ ).getCurrentItem();
let productId = selectedProduct._id;
$w( ‘#shoppingCartIcon1’ ).addToCart(productId)
.then(() => {
console.log( “add product ${productId} success” );
})
. catch ((error) => {
console.log(error);
});
});
First, this all worked perfectly. But once I added some new products, the store/product dataset is now causing the buttons to only add 1 product to the cart, instead of a different one for every product. Can anybody help me with this? It would be highly appreciated