55ok
| Direktori : /home/u307599615/domains/costumeonrent.in/public_html/ |
| Current File : /home/u307599615/domains/costumeonrent.in/public_html/cart.php |
<?php
include("admin/connection.php");
include('include/header.php');
if (!isset($_SESSION['user_id'])) {
echo '<p class="text-center py-5">Please <a href="login.php">Login</a> / <a href="register.php">Register</a> First</p>';
exit;
}
$uid = $_SESSION['user_id'];
$cartQuery = mysqli_query($con, "SELECT * FROM cart WHERE user_id = $uid ORDER BY id DESC");
if (mysqli_num_rows($cartQuery) == 0) {
echo '<p class="text-center py-5">Your cart is empty. <a href="index.php">Continue Shopping</a></p>';
exit;
}
$subTotal = 0;
?>
<style>
/* ---------- Table Styles ---------- */
.cart__section .table th,
.cart__section .table td {
vertical-align: middle;
}
.cart__product img {
border-radius: 8px;
}
.quantity__box {
display: flex;
align-items: center;
}
.quantity__box .btn {
width: 35px;
height: 35px;
font-weight: bold;
}
.quantity__box input {
width: 50px;
text-align: center;
height: 35px;
}
/* ---------- Buttons ---------- */
.btn-primary {
background-color: #28a745;
border-color: #28a745;
}
.btn-primary:hover {
background-color: #218838;
border-color: #1e7e34;
}
/* ---------- Cart Card ---------- */
.cart__table {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.cart__summary {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
/* ---------- Remove Button ---------- */
.cart__remove--btn {
border: none;
background: transparent;
font-size: 18px;
cursor: pointer;
color: #dc3545;
}
/* Responsive */
@media(max-width: 991px) {
.cart__section--inner {
flex-direction: column;
}
.col-lg-8, .col-lg-4 {
max-width: 100%;
}
}
</style>
<main class="main__content_wrapper mt-5 mb-5">
<section class="cart__section py-5" style="background-color: #f7f7f7;">
<div class="container">
<div class="row">
<!-- Cart Items -->
<div class="col-lg-8 mb-4">
<div class="cart__table">
<h3 class="mb-4">Shopping Cart</h3>
<div class="table-responsive">
<table class="table align-middle">
<thead class="table-light">
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php while ($item = mysqli_fetch_assoc($cartQuery)):
$name = htmlspecialchars($item['name']);
$buy = (float)$item['buy'];
$qty = (int)$item['quantity'];
$total = $buy * $qty;
$image = htmlspecialchars($item['cimage']);
$subTotal += $total;
?>
<tr data-id="<?= $item['id']; ?>">
<td>
<div class="cart__product d-flex align-items-center">
<button class="cart__remove--btn remove me-2" type="button" data-id="<?= $item['id']; ?>">❌</button>
<img src="admin/assets/images/categorie/<?= $image; ?>" width="80" class="me-3">
<span><?= $name; ?></span>
</div>
</td>
<td>₹<?= number_format($buy, 2); ?></td>
<td>
<div class="quantity__box">
<button class="btn btn-outline-secondary btn-decrease" type="button" data-id="<?= $item['id']; ?>">-</button>
<input type="text" class="quantity-product mx-1" data-id="<?= $item['id']; ?>" value="<?= $qty; ?>" readonly>
<button class="btn btn-outline-secondary btn-increase" type="button" data-id="<?= $item['id']; ?>">+</button>
</div>
</td>
<td class="total-price">₹<?= number_format($total, 2); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Order Summary -->
<div class="col-lg-4">
<div class="cart__summary">
<h4 class="mb-3">Order Summary</h4>
<div class="d-flex justify-content-between mb-2">
<span>Subtotal:</span>
<span id="subtotal">₹<?= number_format($subTotal, 2); ?></span>
</div>
<div class="d-flex justify-content-between mb-3">
<span>Grand Total:</span>
<span id="total">₹<?= number_format($subTotal, 2); ?></span>
</div>
<p class="text-muted small mb-3">Shipping & taxes calculated at checkout.</p>
<a href="checkout.php" class="btn btn-primary w-100">Proceed to Checkout</a>
</div>
</div>
</div>
</div>
</section>
</main>
<?php include("include/footer.php"); ?>