%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_6ca89795/user/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6ca89795/user/mycartshow.php
<?php
session_start();
include('header.php');
include('../dbcon.php');

if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) {
    header('Location: ../login.php');
    exit();
}

$user_id = $_SESSION['id'];

$stmt = $conn->prepare("
    SELECT ci.id, ci.product_id, ci.quantity, p.price, p.title, p.image 
    FROM cart_items ci 
    JOIN areawecover p ON ci.product_id = p.id 
    WHERE ci.user_id = ?
    ORDER BY ci.id DESC
");
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

$cart_items = [];
$subtotal = 0;

while ($row = $result->fetch_assoc()) {
    $row['total'] = $row['quantity'] * $row['price'];
    $subtotal += $row['total'];
    $cart_items[] = $row;
}
?>

<style>
/* ===== CART UI ===== */
.cart-container {
    margin-top: 30px;
}

.cart-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding: 15px 0;
}

.cart-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cart-left img {
    width: 90px;
    border-radius: 8px;
}

.cart-title {
    font-weight: 600;
}

.cart-price {
    color: #888;
}

.qty-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-box input {
    width: 50px;
    text-align: center;
}

.qty-btn {
    padding: 5px 10px;
    background: #f2f2f2;
    border-radius: 5px;
    text-decoration: none;
}

.cart-total {
    font-weight: bold;
}

.remove-btn {
    color: red;
    text-decoration: none;
}

/* RIGHT SIDE */
.summary-box {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.checkout-btn {
    width: 100%;
    padding: 12px;
    background: #007bff;
    color: #fff;
    border-radius: 8px;
    text-align: center;
    display: block;
    margin-top: 15px;
    text-decoration: none;
}

.checkout-btn:hover {
    background: #0056b3;
}

/* RESPONSIVE */
@media(max-width:768px){
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
</style>

<div class="container cart-container">
    <h2 class="mb-4">🛒 Your Cart</h2>

    <div class="row">
        <!-- LEFT -->
        <div class="col-lg-8">
            <div class="cart-card">

                <?php if(empty($cart_items)){ ?>
                    <p>Your cart is empty 😢</p>
                <?php } ?>

                <?php foreach($cart_items as $item){ ?>
                    <div class="cart-item">
                        
                        <div class="cart-left">
                            <img src="../admin/dataimg/<?php echo $item['image']; ?>">

                            <div>
                                <div class="cart-title">
                                    <?php echo $item['title']; ?>
                                </div>
                                <div class="cart-price">
                                    $<?php echo number_format($item['price'],2); ?>
                                </div>
                            </div>
                        </div>

                        <div class="qty-box">
                            <a href="user-update-cart.php?id=<?php echo $item['id']; ?>&action=minus" class="qty-btn">-</a>

                            <input type="number" value="<?php echo $item['quantity']; ?>">

                            <a href="user-update-cart.php?id=<?php echo $item['id']; ?>&action=plus" class="qty-btn">+</a>
                        </div>

                        <div class="cart-total">
                            $<?php echo number_format($item['total'],2); ?>
                        </div>

                        <a href="user-remove-from-cart.php?id=<?php echo $item['id']; ?>" class="remove-btn">✖</a>

                    </div>
                <?php } ?>

            </div>
        </div>

        <!-- RIGHT -->
        <div class="col-lg-4">
            <div class="summary-box">
                <h4>Order Summary</h4>

                <hr>

                <p>Subtotal: <strong>$<?php echo number_format($subtotal,2); ?></strong></p>

                <a href="../checkout.php" class="checkout-btn">
                    Proceed to Checkout
                </a>
            </div>
        </div>

    </div>
</div>

<!-- Core JS -->
<script src="../assets/vendor/libs/jquery/jquery.js"></script>
<script src="../assets/vendor/libs/popper/popper.js"></script>
<script src="../assets/vendor/js/bootstrap.js"></script>
<script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<script src="../assets/vendor/js/menu.js"></script>
<script src="../assets/js/main.js"></script>

</body>

</html>

VaKeR 2022