Hello all,
I am attempting to add an #addtocart function to my #repeater but am unable to figure out where I went wrong. My goal is to have the query result added to the #cart with the #onclick function for "button2". Here is my code:
```
wixData.query("batteryfitment") .include("title") .contains("year", VINInfo.Results[8].Value) .and(wixData.query("batteryfitment") .contains("make", VINInfo.Results[5].Value) .and(wixData.query("batteryfitment") .contains("model", VINInfo.Results[7].Value))) .find() .then((results1) => { let results = results1; let product = results.items[0].title[0]._id; console.log(results1); $w("#text1").text = results.items[0].title[0].name; $w("#text3").html = results.items[0].title[0].description; $w("#image8").src = results.items[0].title[0].mainMedia; if ($w("#image8").hidden) { $w("#image8").show();} $w("#text5").text = "$" + "" + results.items[0].title[0].price; let productID = results.items[0].title[0]._id; $w("#repeater1").show(); $w("#button2").show(); $w('#button2').onClick(()=>{$w('#shoppingCartIcon1').addToCart("product");});
```
Hi Brittani,
I'm seeing something at a glance here. The addToCart function should have the actual ID from the stores/products collection. Is that what your variable named 'product' is? In other words, do you have that ID in the title field of batteryfitment?
Another thing that I noticed was that it should be .addToCart(product) without the quotes around it as product is a variable. If you put quotes around it, Corvid will treat it as a literal string of "product" and not the variable that is supposed to be holding the product ID.
.