0){ // update the cart $set_sub = mysqli_fetch_assoc($get_sub); $current_qty = $set_sub['qty']; $price = $set_sub['price']; $mod_qty = $current_qty + $qty; $mod_price = $mod_qty * $price; $get_prod_info = mysqli_query($conn, "SELECT * FROM shop_product where product_id = '$product_id'"); $set_prod_info = mysqli_fetch_assoc($get_prod_info); $split = explode("+",$set_prod_info['offer_unit']); $quotient = floor($mod_qty / $split[0]); $remainder = $mod_qty % $split[0]; if($remainder == 0){ $free_qty = $quotient * $split[1]; }else{ $free_qty = $quotient; } $update = "UPDATE tbl_dealer_ef_sub SET qty='$mod_qty', free_qty='$free_qty', tot_price='$mod_price' where order_id='$order_id' and prod_id = '$product_id' and dealer_id = '$dealer_id'"; if(mysqli_query($conn, $update)){ $msg = array("icon"=>"success", "title"=>"Success..", "text"=>"Product Qty updated successfully", "order_id"=>$order_id); echo json_encode($msg); exit; }else{ $msg = array("icon"=>"error", "title"=>"Error..", "text"=>"Product Qty Not updated successfully", "order_id"=>$order_id); echo json_encode($msg); exit; } } } ?>