Hi all,
I’m struggling to add an additional product to cart via API, but it’s not working. The scenario has been already discussed because it’s the classic embroidery that should be added to a main product when a checkbox is checked.
I’ve created the embroidery product and the line properties that should send the information like text and color of the embroidery to the cart. Everything works fine BUT the embroidery product is not added. I don’t get any error, the product is simply not added.
This is my code:
$('.add-to-cart').on('click', function(e){
e.preventDefault();
if( $('#personalize').prop("checked") == true ){
$.ajax({
type: "POST",
url: '/cart/add.js',
data: {quantity: 1,id: 39332170301484}, //this is the variant id of my product
dataType: "json",
success: function(data) {
$('.product-single__form').submit();
},
error: function() {
alert('error');
}
});
} else {
$(this).parents('form').submit();
}
});