There is a set of products and you need to add all the goods in the kit to the cart. Now I add the product like this:
<a style="cursor:pointer" class="btn-buy" onclick="addCart(this);">Купить</a> <input type="hidden" value="<?=$produсt->id?>" name="id"/> When you click on "Купить" , the addcart function is addcart , to which one product id is sent.
function addCart(btn) { $this = $(btn); var id = $this.siblings('input[name=id]').val(); $.ajax({ url: '/cart/add_cart', dataType : "json", type : 'post', data : { 'id':id }, success: function (data, textStatus) { $(".total_count").text(data.total_count + " шт."); $(".sum").text(data.total_price); $('.name_modal').html(data.addProduct.title); $('.price_modal').html(data.addProduct.price); $('.img_modal').attr('src', '/' + data.addProduct.img); $('#myModal').reveal({}); } }); } But how to add a few products when you click on "Купить" ? An example for you to understand what a kit is. Below the product is shown kit. I want to add a "Купить" button, and so that all the items in the kit are added to the cart.