I created a product list page with a repeater. It is connected to wix Products/Stores dataset.(#dataset2)
The product information fields are connected to a custom database collection ("360precisionproducts") to retrieve the unique product info.
Below is my code which I couldn't get to work.
Hope someone can help.
Thanks.
![](https://static.wixstatic.com/media/a27d24_f652c2b73d404470bacfdd168f94e4e6~mv2_d_4729_2615_s_4_2.png/v1/fill/w_980,h_542,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_f652c2b73d404470bacfdd168f94e4e6~mv2_d_4729_2615_s_4_2.png)
$w.onReady( function () {
$w("#cartButton").onClick( (event) => {
let $item = $w.at(event.context); // Get container scope
let selectedProduct = $item('#dataset2').getCurrentItem();
let productId = selectedProduct._id;
$w('#shoppingCartIcon1').addToCart(productId)
.then(() => {
// Item added to the shopping cart
console.log("add product ${productId} success");
})
.catch((error) => {
// Catch an error that occurs
console.log("Error: ${error.stack}");
});
} );
i have same issue please wix help
Hey,
There is a similar post, I think this might be what you are looking for:
https://www.wix.com/corvid/forum/community-discussion/add-button-to-add-to-cart
Good luck!