ok
Direktori : /home2/selectio/www/thecomponents.in/api/ |
Current File : /home2/selectio/www/thecomponents.in/api/view-cart.php |
<?php ob_start(); error_log('working'); session_start(); include '../config/config.php'; if(isset($_POST['type']) && $_POST['type']=='view_cart_details'){ $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_amount=""; if($cart_count>0){ $data.='<table class="shop-table cart-table"> <thead> <tr> <th> <span>Product</span> </th> <th> <span>Name</span> </th> <th><span>Price</span></th> <th> <span>Quantity</span> </th> <th> <span>Subtotal</span> </th> <th>Remove</th> </tr> </thead> <tbody>'; foreach($price_result as $price_result_datas){ $total_amount+= $price_result_datas['price'] * $price_result_datas['qty']; $sum_amount = $price_result_datas['price'] * $price_result_datas['qty']; $data.='<tr data-rowid="'.$price_result_datas['cart_id'].'"> <td class="product-thumbnail" style="text-align:center;"> <figure> <a href="#"> <img src="admin/'.$price_result_datas['image'].'" width="100" height="100" alt="product"> </a> </figure> </td> <td class="product-name" style="text-align:center;"> <div class="product-name-section"> <a href="#">'.$price_result_datas['name'].'</a> </div> </td> <td class="product-name" style="text-align:center;"> <span class="amount product_price">₹'.number_format($price_result_datas['price'],2).'</span> </td> <td class="product-name" style="text-align:center;"> <span class="amount pro_quantity">'.$price_result_datas['qty'].'</span> </td> <td class="product-subtotal" style="text-align:center;"> <span class="amount product_total_amount">'.$sum_amount.'</span> </td> <td class="product-close" style="text-align:center;"> <a href="#" onclick="remove_cart('.$price_result_datas['cart_id'].')" class="product-remove" title="Remove this product"> <i class="fas fa-times"></i> </a> </td> </tr>'; } $data.='</tbody>'; }else{ $data.='No Products'; } if($cart_count>0) { $return_arr['total_card_price'] = $data; $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); } ?>