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'"); $update = "UPDATE tbl_dealer_ef_sub SET qty='$mod_qty', free_qty='0', tot_price='$mod_price', cust_edit='#3ef80b' 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,"status"=>'2'); echo json_encode($msg); exit; }else{ $msg = array("icon"=>"error", "title"=>"Error..", "text"=>"Product Qty Not updated successfully", "order_id"=>$order_id, "status"=>'3'); echo json_encode($msg); exit; } }else{ $get_prod_info = mysqli_query($conn, "SELECT offer_unit,price,vstatus FROM shop_product where product_id = '$product_id'"); $set_prod_info = mysqli_fetch_assoc($get_prod_info); $vstatus = $set_prod_info['vstatus']; $price = $set_prod_info['price']; $tot_price = $qty * $price; $insert = "INSERT INTO tbl_dealer_ef_sub (order_id,dealer_id,prod_id,qty,free_qty,price,tot_price,vstatus,ref_order_id,stock_status,qty_edit,cust_edit,order_date_time) VALUES ('$order_id','$dealer_id','$product_id','$qty','0','$price','$tot_price','$vstatus',NULL,'ordered',NULL,'#0bf8ba', '$date') "; if(mysqli_query($conn, $insert)){ $msg = array("icon"=>"success", "title"=>"Success..", "text"=>"Product Qty updated successfully", "order_id"=>$order_id,"status"=>'2'); echo json_encode($msg); exit; }else{ $msg = array("icon"=>"error", "title"=>"Error..", "text"=>"Product Qty Not updated successfully", "order_id"=>$order_id, "status"=>'3'); echo json_encode($msg); exit; } } } ?>