2018-07-24 13:50


  • laravel
  • php
  • ajax
  • javascript
  • jquery

I need someone to help me please to insert multiple products to cart, adding single one is working fine but I have one product which inserting with no issue and related products which have checkboxes where I need to add it but dont know how

enter image description here

ajax for adding product:

  $('.add_to_cart').on("click", function () { 
    var id = ($("#item_id").val());
      url: 'cart/' + id+'/edit', 
      type: "get", 
      success: function (data) { 


add in controller

public function edit(Request $request,$id)

  $products = Cart::content();
  foreach($products as $Product){
    echo '<div class="OrderItem_root styles_base styles_spacing-base">
    <div class="OrderItem_quantity styles_just-right styles_base styles_spacing-base">'.$Product->qty.'</div>
    <div class="OrderItem_container">
    <div class="OrderItem_category"></div>
    <div class="OrderItem_itemHeader">
    <div id="cartprice" class="OrderItem_total">$'.$Product->price*$Product->qty.'</div>
    <input id="mycartprice" type="text" name="mycartprice" value="'.$Product->price.'"  hidden="">
    <button class="remove_item OrderItem_action Button_root" data-id="'.$Product->rowId.'" data-price="'.$Product->price*$Product->qty.'" data-qty="'.$Product->qty.'" type="submit">Remove</button>

related items

foreach($products as $Product){ 

   echo '<div class="SuggestedItem_container">  
    <input  id="ppleadd" type="checkbox" onchange = "AutoCalculateMandateOnChange(this)"> 

    <span id="related_item" class="SuggestedItem_name">'.$ProductDetails->product_title.'</span><span class="SuggestedItem_price styles_small styles_base styles_spacing-base">+$'.$ProductDetails->product_price.'</span></div></div> 

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享