ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/public_html/ramali.in/api/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/public_html/ramali.in/api/cart.php

<?php
session_start();
include"../config/config.php";
if(isset($_POST['type']) && $_POST['type']=='add_to_cart') 
{
    try
    {
        $variant_id = "";
        if($_POST['variant_id']){
            $variant_id = $_POST['variant_id'] ;
        }
        
        if($_PSOT['product_variant_id']){
           $variant_id = $_PSOT['product_variant_id'];
        }
        
        if(isset($_SESSION['ramali_textiles'])){    
        $user_id=$_SESSION['ramali_textiles']['id'];
        
        $statementp=$pdo->prepare("SELECT * FROM `cart` where product_id=? AND user_id=? AND product_variant_id=?");
        error_log("SELECT * FROM `cart` where product_id=? AND user_id=? AND product_variant_id=?");
        
        $statementp->execute(array($_POST['product_id'],$user_id,$variant_id));
        
        
        $totalp=$statementp->rowCount();
        $resultp=$statementp->fetchAll(PDO::FETCH_ASSOC);
        if($totalp==0)
        {
          
        
            
                 $statement=$pdo->prepare("INSERT INTO `cart`(`user_id`,`product_variant_id`,`product_id`) VALUES (?,?,?)");
                 $result=$statement->execute(array($user_id,$variant_id,$_POST['product_id']));
                 if($result)
                 {
                        $statementp=$pdo->prepare("SELECT * FROM `cart` where user_id=? AND product_id=? AND product_variant_id=? group by product_variant_id");
                        $statementp->execute(array($user_id,$_POST['product_id'],$variant_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);
    }   
    }

?>

Zerion Mini Shell 1.0