ok
Direktori : /home2/selectio/public_html/ramali.in/api/ |
Current File : /home2/selectio/public_html/ramali.in/api/cart-details.php |
<?php session_start(); include"../config/config.php"; if(isset($_POST['type']) && $_POST['type']=='add_to_cart') { try { if(isset($_SESSION['ramali_textiles'])){ $user_id=$_SESSION['ramali_textiles']['id']; $statementp=$pdo->prepare("SELECT * FROM `cart` where product_id=? and user_id=?"); $statementp->execute(array($_POST['product_id'],$user_id)); $totalp=$statementp->rowCount(); $resultp=$statementp->fetchAll(PDO::FETCH_ASSOC); if($totalp==0) { $statement=$pdo->prepare("INSERT INTO `cart`(`user_id`, `product_id`) VALUES (?,?)"); $result=$statement->execute(array($user_id,$_POST['product_id'])); if($result) { $statementp=$pdo->prepare("SELECT * FROM `cart` where user_id=? group by product_id"); $statementp->execute(array($user_id)); $cart_count=$statementp->rowCount(); $return_arr['cart_count']=$cart_count; $return_arr['message'] = 'Addtocard successfully added!'; $return_arr['status']=200; } else { $return_arr['message']="Please add product details!"; $return_arr['status']=400; } }else{ $return_arr['message']="product already in Addtocart!"; $return_arr['status']=400; } }else{ //session not value else part $return_arr['message']="Please login!"; $return_arr['status']=500; } echo json_encode($return_arr); } catch(Exception $e){ $return_arr['message']='0987'.$e; $return_arr['status']=500; echo json_encode($return_arr); } } ?>