ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/home2/selectio/www/thecomponents.in/api/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/home2/selectio/www/thecomponents.in/api/add-to-card.php

<?php
ob_start();
error_log('working');
session_start();
include '../config/config.php';

if(isset($_POST['type']) && $_POST['type']=='remove' && isset($_POST['card_id']) && $_POST['card_id']!=0){
          $statement=$pdo->prepare("DELETE FROM `cart` WHERE id=? and user_id=?");
          $result = $statement->execute(array($_POST['card_id'],$_SESSION['caliber']['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['caliber']['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['caliber']['id'],$_POST['pro_id']));
      
}
    
if(isset($_POST['type']) && $_POST['type']=='c_count'){

        
        $price_sql=$pdo->prepare("SELECT cart.id,cart.user_id,cart.qty,cart.product_id,products.name,users.name,product_variant.price
        FROM cart INNER JOIN products ON cart.product_id=products.id INNER JOIN users ON users.id=cart.user_id INNER JOIN product_variant ON 
        product_variant.product_id = products.id WHERE cart.user_id=?");
        
        $price_sql->execute(array($_SESSION['caliber']['id']));
        $price_result = $price_sql->fetchAll(PDO::FETCH_ASSOC);
        $cart_count=$price_sql->rowCount();
        $price_result_cart = 0.00;
        $total=0;
        foreach($price_result as $dats){
            
            $total+= $dats['price'] * $dats['qty'];
            
        }
        
      if($cart_count>0)
    {
      
        $return_arr['cart_count'] = $cart_count;
        $return_arr['total_card_price'] = '<i class="bi bi-currency-rupee" style="font-size: 14px;"></i>'.$total;
        $return_arr['status'] = 200;
        
        
    }else{
        $return_arr['cart_count'] = 0;
         $return_arr['total_card_price'] = '<i class="bi bi-currency-rupee" style="font-size: 14px;"></i>'.$total;
        $return_arr['status'] = 400;
    }
    echo json_encode($return_arr);
}
         
    
    

?>

Zerion Mini Shell 1.0