ok
Direktori : /home2/selectio/public_html/ramali.in/ui-api/ |
Current File : //home2/selectio/public_html/ramali.in/ui-api/api-cart.php |
<?php ob_start(); error_log('working'); session_start(); include '../config/config.php'; if(isset($_POST['type']) && $_POST['type']=='remove' && isset($_POST['delete_id']) && $_POST['delete_id']!=0){ error_log("delete page is working"); $statement=$pdo->prepare("DELETE FROM `cart` WHERE id=? and user_id=?"); $result = $statement->execute(array($_POST['delete_id'],$_SESSION['ramali_textiles']['id'])); if($result) { $return_arr['message'] = "Cart Product Removed Successfully"; $return_arr['status']=200; }else{ $return_arr['message']= "Something Wrong"; $return_arr['status']=400; } echo json_encode($return_arr); } if(isset($_POST['type']) && $_POST['type']=='total_quantity' && isset($_POST['pro_id']) && $_POST['pro_id']!=0){ error_log('condition is working'); $qyt="UPDATE cart SET qty=".$_POST['quantity']." WHERE user_id=".$_SESSION['ramali_textiles']['id']." AND product_id=".$_POST['pro_id']; error_log($qyt); $statement=$pdo->prepare("UPDATE cart SET qty=? WHERE user_id=? AND id=?"); $statement->execute(array($_POST['quantity'],$_SESSION['ramali_textiles']['id'],$_POST['pro_id'])); } if(isset($_POST['type']) && $_POST['type']=='c_count'){ $statementp=$pdo->prepare("SELECT * FROM `cart` where user_id=? group by product_id"); $statementp->execute(array($_SESSION['ramali_textiles']['id'])); $cart_count=$statementp->rowCount(); if($cart_count>0) { $return_arr['cart_count'] = $cart_count; $return_arr['status'] = 200; }else{ $return_arr['cart_count'] = 0; $return_arr['status'] = 400; } echo json_encode($return_arr); } if(isset($_POST['type']) && $_POST['type']=='shipping_amount'){ $ids=$_POST['id']; $per_weight = $_POST['per_weight']; error_log("PER WEIGHT KG".$per_weight); error_log("SELECT * FROM shipping WHERE id=".$ids); $shipping = $pdo->prepare("SELECT * FROM shipping WHERE id=".$ids); $shipping->execute(); $shipping_result = $shipping->fetchAll(PDO::FETCH_ASSOC); $shipping_count = $shipping->rowCount(); if($shipping_count>0) { $shipping_amount = $shipping_result[0]['weight_amount'] * $per_weight; $return_arr['shipping'] = $shipping_result[0]['weight_amount'] * $per_weight; $return_arr['Shipping_amount'] = '<input type="text" name=""weight_amount value="'.$shipping_amount. '"'; $return_arr['status'] = 200; }else{ $return_arr['shipping'] = 0; $return_arr['status'] = 400; } echo json_encode($return_arr); } if(isset($_POST['type']) && $_POST['type']=='state_select'){ $ids=$_POST['id']; $shipping = $pdo->prepare("SELECT * FROM shipping WHERE state_id=".$ids); $shipping->execute(); $shipping_result = $shipping->fetchAll(PDO::FETCH_ASSOC); $shipping_count = $shipping->rowCount(); $data = ""; if($shipping_count>0){ foreach($shipping_result as $shipping_data){ $data.= '<option value="'.$shipping_data['id'].'"> '.$shipping_data['district'].' </option>'; } }else{ $data.= '<option value="0"> No District </option>'; } if($shipping_count>0) { $return_arr['district'] = $data; $return_arr['status'] = 200; }else{ $return_arr['district'] = $data; $return_arr['status'] = 400; } echo json_encode($return_arr); } ?>