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.
$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!