I want to create a custom add to cart button to add my 3 items to the cart with 2 quantities for each.
To add three products to the cart, I did the following:
<a id="buy" class="single_add_to_cart_button shop-skin-btn shop-flat-btn alt" href="#">ADD MY PRODUCT</a>
$ p_id = my product id, for example: 45,99,152
<script>
jQuery('#buy').click(function(e) {
e.preventDefault();
var myStringArray = [<?php echo $p_id; ?>];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
addToCart(myStringArray[i]);
}
return true;
});
function addToCart(p_id) {
$.get('/glassful/?post_type=product&add-to-cart=' + p_id, function() {
$(".show_success").show();
});
}
</script>
He will add my product to the basket, but with only 1 quantity. Please let me know how I can add the quantity. I want to add 2 quantities of each product.
The average value, when clicking on add to cart, three products will be added to the cart with 2 quantities each.
Thanks for the help in advance.
user5238788