You don’t actually need to put a quantity in your code if you are just wanting the one product to be added to the cart.
As mentioned in the addToCart function info on the Wix CartIcon API.
Use the optional quantity parameter to add more than one product unit to the shopping cart at one time. If quantity is omitted, one product unit will be added.
Add a product to the cart from a button click
$w("#myButton").onClick( () => {
$w("#myShoppingCartIcon").addToCart("ea77f230-558f-0ba565e8f827")
.then( () => {
console.log("Product added");
} )
.catch( (error) => {
console.log(error);
} );
} );
So, providing you do actually have the correct productID listed for your required product.
Your code should be something like the add product to cart with options example, however simply without the additional 2 for the quantity and the choices for size and the extra custom info lines for the second product.
Add a product to the cart with options
$w('#shoppingCartIcon1').addToCart("ea77f230-558f-0ba565e8f827", 2, {
"choices": {
"Size": "Small"
},
"customTextFields": [ {
"title": "Personalization 1",
"value": "Personalized Text 1"
},
{
"title": "Personalization 2",
"value": "Personalized Text 2"
} ]
} )
.then( () => {
console.log("Product added");
} )
.catch( (error) => {
console.log(error);
} );