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/side-card-ui.php

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

   
if(isset($_POST['type']) && $_POST['type']=='product_details'){
    
    if($_SESSION['caliber']){
        
        error_log("SELECT cart.id as cart_id,cart.user_id,cart.qty,cart.product_id,products.name  as product_name,
        users.name,products.image,product_variant.stock,product_variant.price
        FROM cart LEFT JOIN products ON cart.product_id=products.id LEFT JOIN users ON users.id=cart.user_id LEFT JOIN product_variant ON 
        product_variant.product_id = cart.product_id WHERE cart.user_id=".$_SESSION['caliber']['id']);
        
        $price_sql=$pdo->prepare("SELECT cart.id as cart_id,cart.user_id,cart.qty,cart.product_id,products.name  as product_name,
        users.name,products.image,product_variant.stock,product_variant.price
        FROM cart LEFT JOIN products ON cart.product_id=products.id LEFT JOIN users ON users.id=cart.user_id LEFT JOIN product_variant ON 
        product_variant.product_id = cart.product_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();
        $data="";
        $total=0;
        
        $data.='<div class="dropdown-box scrollable">
                <div class="canvas-header">
                    <h4 class="canvas-title">Shopping Cart</h4>
                    <a href="#" class="btn btn-dark btn-link btn-icon-right btn-close">close <i class="d-icon-arrow-right"></i>
                      <span class="sr-only">Cart</span>
                    </a>
                  </div>
                  <div class="products scrollable">';
                  if($cart_count>0){
                      foreach($price_result as $total_card_datas){
                          
                          
                          
                          $total+= $total_card_datas['price'] * $total_card_datas['qty'];
                            $data.='<div class="product product-cart">
                                <figure class="product-media">
                                  <a href="product1.php">
                                      <img src="admin/'.$total_card_datas['image'].'" alt="product" width="80" height="88" />
                                  </a>
                                  <button onclick="remove_cart('.$total_card_datas['cart_id'].')" class="btn btn-link btn-close">
                                    <i class="fas fa-times"></i>
                                    <span class="sr-only">Close</span>
                                  </button>
                                </figure>
                                <div class="product-detail">
                                  <a href="product1.php" class="product-name">'.$total_card_datas['product_name'].'</a>
                                  <div class="price-box">
                                    <span class="product-quantity">'.$total_card_datas['qty'] .'</span>
                                    <span class="product-price">'.$total_card_datas['price'].'</span>
                                    <input type="hidden" value="'. $total_card_datas['price'] * $total_card_datas['qty']. '" class="cart-price" >
                                </div>
                            </div></div>'; }
                      
                  }
                 $data.='<div class="cart-total">
                    <label>Subtotal:</label>
                    <span class="price">₹'.$total. '</span>
                  </div>
                  <div class="cart-action">
                    <a href="cart.php" class="btn btn-dark btn-link">View Cart</a>
                    <a href="checkout.php" class="btn btn-dark">
                      <span>Go To Checkout</span>
                    </a>
                  </div>
                </div>'; } else{
                    
                    $price_sql=$pdo->prepare("SELECT cart.id,cart.user_id,cart.product_id,cart.qty,products.name  as product_name,
        users.name,SUM(product_variant.price) AS total_price,products.image,product_variant.stock,product_variant.price
        FROM cart LEFT JOIN products ON cart.product_id=products.id LEFT JOIN users ON users.id=cart.user_id LEFT 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();
        $data="";
        
        $data.='<div class="dropdown-box scrollable">
                <div class="canvas-header">
                    <h4 class="canvas-title">Shopping Cart</h4>
                    <a href="#" class="btn btn-dark btn-link btn-icon-right btn-close">close <i class="d-icon-arrow-right"></i>
                      <span class="sr-only">Cart</span>
                    </a>
                  </div>
                  <div class="products scrollable"><div class="cart-total">
                    <label>Subtotal:</label>
                    <span class="price">Please Login..</span>
                  </div>
                </div>';
        
                }
        
      if($cart_count>0)
    {
     
        $return_arr['total_card_price'] = $data;
         $return_arr['total_price'] = $total;
        $return_arr['status'] = 200;
        
        
    }else{
        $return_arr['total_card_price'] = $data;
        $return_arr['cart_count'] = 0;
        $return_arr['status'] = 400;
    }
    echo json_encode($return_arr);
}
         
    
    

?>

Zerion Mini Shell 1.0