🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:cart.php
<?php require_once __DIR__ . '/../includes/config.php'; require_once __DIR__ . '/../includes/db.php'; require_once __DIR__ . '/../includes/functions.php'; $page = 'cart'; $page_title = 'Shopping Cart'; require_once '../includes/header.php'; require_once '../includes/navbar.php'; $cart_items = get_cart_items(); $cart_total = get_cart_total(); $shipping_cost = $cart_total >= FREE_SHIPPING_MIN ? 0 : SHIPPING_COST; $tax = ($cart_total * TAX_RATE) / 100; $discount = 0; if (isset($_SESSION['coupon'])) { $discount = calculate_discount($_SESSION['coupon'], $cart_total); if (isset($_GET['remove_coupon'])) { unset($_SESSION['coupon']); header('Location: ' . SITE_URL . 'pages/cart.php'); exit; } } $grand_total = $cart_total + $shipping_cost + $tax - $discount; ?> <main> <!-- Breadcrumb --> <section style="background: var(--light-marble); padding: 20px 0;"> <div class="container"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0"> <li class="breadcrumb-item"><a href="<?= SITE_URL ?>">Home</a></li> <li class="breadcrumb-item active">Shopping Cart</li> </ol> </ol> </div> </section> <!-- Cart Section --> <section class="cart-section" style="padding: 60px 0;"> <div class="container"> <h1 style="font-size: 2.5rem; margin-bottom: 40px;">Shopping Cart</h1> <?php if (count($cart_items) > 0): ?> <div class="row g-4"> <!-- Cart Items --> <div class="col-lg-8"> <div class="cart-items" style="background: var(--white); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm);"> <table class="table mb-0" style="background: transparent;"> <thead style="background: var(--light-marble);"> <tr> <th style="padding: 15px 20px; border: none; font-weight: 600;">Product</th> <th style="padding: 15px; border: none; font-weight: 600; text-align: center;">Price</th> <th style="padding: 15px; border: none; font-weight: 600; text-align: center;">Quantity</th> <th style="padding: 15px; border: none; font-weight: 600; text-align: center;">Total</th> <th style="padding: 15px; border: none; font-weight: 600; text-align: center;"></th> </tr> </thead> <tbody> <?php foreach ($cart_items as $item): $price = $item['sale_price'] > 0 ? $item['sale_price'] : $item['regular_price']; $item_total = $price * $item['quantity']; $image_url = SITE_URL . 'assets/images/no-image.jpg'; if (!empty($item['thumbnail'])) { if (file_exists(UPLOADS_PATH . 'products/' . $item['thumbnail'])) { $image_url = UPLOADS_URL . 'products/' . $item['thumbnail']; } elseif (file_exists(UPLOADS_PATH . 'settings/' . $item['thumbnail'])) { $image_url = UPLOADS_URL . 'settings/' . $item['thumbnail']; } } ?> <tr style="border-bottom: 1px solid var(--gray-200);"> <td style="padding: 20px; border: none; vertical-align: middle;"> <div style="display: flex; gap: 15px; align-items: center;"> <a href="<?= SITE_URL ?>pages/product.php?slug=<?= $item['slug'] ?>" style="width: 80px; height: 80px; border-radius: 12px; overflow: hidden; flex-shrink: 0;"> <img src="<?= function_exists('img_url') ? img_url($image_url) : $image_url ?>" alt="<?= htmlspecialchars($item['name']) ?>" style="width: 100%; height: 100%; object-fit: cover;" onerror="this.onerror=null;this.src='<?= SITE_URL ?>assets/images/no-image.jpg';"> </a> <div> <a href="<?= SITE_URL ?>pages/product.php?slug=<?= $item['slug'] ?>" style="color: var(--dark-text); text-decoration: none; font-weight: 500; display: block; margin-bottom: 5px;"> <?= htmlspecialchars($item['name']) ?> </a> <?php if ($item['variation_details']): ?> <small class="text-muted"><?= htmlspecialchars($item['variation_details']) ?></small> <?php endif; ?> </div> </div> </td> <td style="padding: 15px; text-align: center; vertical-align: middle; border: none; font-weight: 600; color: var(--primary-rose-gold);"> <?= format_currency($price) ?> </td> <td style="padding: 15px; text-align: center; vertical-align: middle; border: none;"> <div class="qty-wrapper" style="display: inline-flex;"> <button type="button" class="qty-btn qty-minus">−</button> <input type="number" value="<?= $item['quantity'] ?>" min="1" class="qty-input cart-qty-input" data-item-id="<?= $item['id'] ?>"> <button type="button" class="qty-btn qty-plus">+</button> </div> </td> <td style="padding: 15px; text-align: center; vertical-align: middle; border: none; font-weight: 600;"> <?= format_currency($item_total) ?> </td> <td style="padding: 15px; text-align: center; vertical-align: middle; border: none;"> <button class="remove-cart-item" data-item-id="<?= $item['id'] ?>" style="background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 1.2rem; padding: 5px;" title="Remove"> <i class="fas fa-trash-alt"></i> </button> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <div style="margin-top: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;"> <a href="<?= SITE_URL ?>pages/shop.php" class="btn-outline-luxury"> <i class="fas fa-arrow-left"></i> Continue Shopping </a> <!-- Coupon Code --> <div class="coupon-section" style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;"> <?php if (isset($_SESSION['coupon'])): ?> <div style="background: var(--soft-pink); padding: 10px 20px; border-radius: 50px; display: flex; align-items: center; gap: 10px;"> <span><strong><?= $_SESSION['coupon']['code'] ?></strong> applied! -<?= format_currency($discount) ?></span> <a href="?remove_coupon=1" style="color: var(--danger); text-decoration: none;"><i class="fas fa-times"></i></a> </div> <?php else: ?> <input type="text" id="coupon-code" placeholder="Coupon code" class="form-control" style="border-radius: 50px; padding: 10px 20px; max-width: 200px;"> <button id="apply-coupon" class="btn-luxury" style="padding: 10px 20px;"> <i class="fas fa-tag"></i> Apply Coupon </button> <?php endif; ?> </div> </div> </div> <!-- Cart Summary --> <div class="col-lg-4"> <div class="cart-summary" style="background: var(--white); border-radius: 16px; padding: 30px; box-shadow: var(--shadow-sm); position: sticky; top: 100px;"> <h3 style="font-size: 1.3rem; margin-bottom: 25px; font-family: var(--font-primary); font-weight: 600;">Cart Summary</h3> <div style="border-bottom: 1px solid var(--gray-200); padding-bottom: 20px; margin-bottom: 20px;"> <div style="display: flex; justify-content: space-between; margin-bottom: 12px;"> <span>Subtotal</span> <span style="font-weight: 600;"><?= format_currency($cart_total) ?></span> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 12px;"> <span>Shipping</span> <span style="font-weight: 600;"><?= $shipping_cost > 0 ? format_currency($shipping_cost) : '<span style="color: var(--success);">FREE</span>' ?></span> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 12px;"> <span>Tax (<?= TAX_RATE ?>%)</span> <span style="font-weight: 600;"><?= format_currency($tax) ?></span> </div> <?php if ($discount > 0): ?> <div style="display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--success);"> <span>Discount</span> <span style="font-weight: 600;">-<?= format_currency($discount) ?></span> </div> <?php endif; ?> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 25px; font-size: 1.2rem;"> <strong>Total</strong> <strong style="color: var(--primary-rose-gold);" class="cart-total"><?= format_currency($grand_total) ?></strong> </div> <a href="<?= SITE_URL ?>pages/checkout.php" class="btn-luxury w-100" style="margin-bottom: 15px; justify-content: center;"> Proceed to Checkout <i class="fas fa-arrow-right"></i> </a> <a href="<?= SITE_URL ?>pages/shop.php" class="btn-outline-luxury w-100" style="justify-content: center;"> <i class="fas fa-shopping-bag"></i> Continue Shopping </a> <!-- Trust Badges --> <div style="margin-top: 25px; padding-top: 25px; border-top: 1px solid var(--gray-200);"> <div style="display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 0.85rem; color: var(--gray-600);"> <i class="fas fa-shield-alt" style="color: var(--primary-rose-gold);"></i> <span>Secure SSL Encrypted Checkout</span> </div> <div style="display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 0.85rem; color: var(--gray-600);"> <i class="fas fa-undo" style="color: var(--primary-rose-gold);"></i> <span>30-Day Money Back Guarantee</span> </div> <div style="display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--gray-600);"> <i class="fas fa-truck" style="color: var(--primary-rose-gold);"></i> <span>Free Shipping over <?= format_currency(FREE_SHIPPING_MIN) ?></span> </div> </div> </div> </div> </div> <?php else: ?> <div class="text-center py-5" style="background: var(--white); border-radius: 16px; box-shadow: var(--shadow-sm);"> <i class="fas fa-shopping-cart" style="font-size: 5rem; color: var(--soft-pink); margin-bottom: 20px;"></i> <h3>Your cart is empty</h3> <p class="text-muted mb-4">Looks like you haven't added anything to your cart yet</p> <a href="<?= SITE_URL ?>pages/shop.php" class="btn-luxury"> <i class="fas fa-shopping-bag"></i> Start Shopping </a> </div> <?php endif; ?> </div> </section> </main> <?php require_once '../includes/footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder