Hello, I have an issue while trying to add a product to the cart through code. I created a custom product page with 3 preparametered options on my product database, and a 4th one which is a custom text fullfilled by the customer:
I am using the “addProducts” function as said in the online resources. For the options they are registered well with the product in the cart, but not the cutomTextFields… The console.log array is 0, no value is in there. I configured my product with the options to fill which are registered well, and a customtextfields. Through the standard product page it is working, but not on the custom one…
Here is my code
$w('#buttonAjoutPanier').onClick((event) => {
const products = [{
"productId": myproductid,
"quantity": 1,
"options": { choices: selectedOptions },
"customTextFields": [{
"title": "Nom",
"value": "testvalue"
}]
}]
cart.addProducts(products)
.then((updatedCart) => {
// Products added to cart
const cartId = updatedCart._id;
const cartLineItems = updatedCart.lineItems;
console.log(cartLineItems)
})
.catch((error) => {
// Products not added to cart
console.error(error);
});
});