BLACKSITE
:
216.73.217.4
:
104.37.75.190 / alpenpass.ca
:
Linux server3.pointsplan.com 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
:
/
home
/
apca
/
www
/
Upload File:
files >> /home/apca/www/cart.php
<?php session_start(); include('includes/config.php'); // Ensure the user is logged in if (!isset($_SESSION['id'])) { die("Please log in to view your cart."); } $user_id = $_SESSION['id']; // Fetch the cart items for the current user $query = $dbh->prepare("SELECT * FROM cart WHERE user_id = :user_id"); $query->execute([':user_id' => $user_id]); $cart_items = $query->fetchAll(PDO::FETCH_ASSOC); // Calculate the total price $total_price = 0; foreach ($cart_items as $item) { $total_price += ($item['price'] * $item['quantity']); $totalGST +=($item['price'] * $item['quantity']) * (intval($item['ProductsGSTRate'])/100); $totalPST +=($item['price'] * $item['quantity']) * (intval($item['ProductsPSTRate'])/100); } include("includes/head.php"); include("includes/header.php"); ?> <style> .updateMessage{ padding: 40px; border-radius: 20px; background-color:#CCFFCC; font-size: 24px; text-align: center; width: 100%; } </style> <body> <div class="container" style="min-height: 500px;"> <div class="row justify-content-center"> <div class="col-sm-12"> <body> <div class="container mt-5"> <h1>Shopping Cart</h1> <?php if($_GET['updateMessage']){ echo "<br /><div id='myDiv' class='updateMessage'>".$_GET['updateMessage']."</div><br />"; } ?> <table class="table table-bordered"> <thead> <tr> <th>Product Name</th> <th>Model Number</th> <th>Size</th> <th>Colour</th> <th>Price</th> <th>Quantity</th> <th>Total</th> <th>Actions</th> </tr> </thead> <tbody> <?php if (!empty($cart_items)) : ?> <?php foreach ($cart_items as $item) : ?> <tr> <td><?= htmlentities($item['product_name']); ?></td> <td><?= htmlentities($item['model_number']); ?></td> <td><?= htmlentities($item['size']); ?></td> <td><?= htmlentities($item['color']); ?></td> <td style="text-align: right; padding-right:10px;">$<?= number_format($item['price'], 2); ?></td> <td> <form method="post" action="update_cart.php" style="display:inline;"> <input type="hidden" name="id" value="<?= $item['product_id']; ?>"> <input type="number" name="quantity" value="<?= $item['quantity']; ?>" min="1" style="width: 60px;"> </td> <td style="text-align: right; padding-right:10px;">$<?= number_format($item['price'] * $item['quantity'], 2); ?></td> <td> <button type="submit" class="btn btn-primary btn-sm" style="border: none; margin-top:5px; width:70px;">Update</button> </form> <a href="delete_from_cart.php?product_id=<?= $item['product_id']; ?>" class="btn btn-danger btn-sm" style="text-decoration: none; margin-top:5px; width:70px;">Delete</a> </td> </tr> <?php endforeach; ?> <?php else : ?> <tr> <td colspan="5" class="text-center">Your cart is empty.</td> </tr> <?php endif; ?> <tr><td colspan="5"> </td><td><strong>Sub Total</strong></td><td style="text-align: right; padding-right:10px;"><strong>$<?= number_format($total_price, 2); ?></strong></td></tr> <tr><td colspan="5"> </td><td><strong>GST</strong></td><td style="text-align: right; padding-right:10px;"><strong>$<?= number_format($totalGST, 2); ?></strong></td></tr> <tr><td colspan="5"> </td><td><strong>PST</strong></td><td style="text-align: right; padding-right:10px;"><strong>$<?= number_format($totalPST, 2); ?></strong></td></tr> <tr><td colspan="5"> </td><td><strong>Grand Total</strong></td><td style="text-align: right; padding-right:10px;"><strong>$<?= number_format(($total_price+$totalGST+$totalPST), 2); ?></strong></td></tr> </tbody> </table> <div class="d-flex justify-content-between" style="margin-bottom: 40px;"> <a href="product_listing.php" class="btn btn-secondary">Continue Shopping</a> <?php if (!empty($cart_items)) : ?> <form method="post" action="checkout.php"> <button type="submit" class="btn btn-success">Checkout</button> </form> <?php endif; ?> </div> </div> </div> </div> </div> <!--Footer --> <?php include('includes/footer.php');?> <!-- /Footer--> <!--Back to top--> <div id="back-top" class="back-top"> <a href="#top"><i class="fa fa-angle-up" aria-hidden="true"></i> </a> </div> <!--/Back to top--> <!--Login-Form --> <?php include('includes/login.php');?> <!--/Login-Form --> <!--Register-Form --> <?php include('includes/registration.php');?> <!--/Register-Form --> <!--Forgot-password-Form --> <?php include('includes/forgotpassword.php');?> <script src="assets/js/jquery.min.js"></script> <script> function fadeOutEffect(element, duration) { let opacity = 1; // Initial opacity const interval = 50; // Interval in ms const decrement = interval / duration; // Decrease per step const fade = setInterval(() => { if (opacity <= 0) { clearInterval(fade); element.style.display = 'none'; // Hide the element after fading out } else { opacity -= decrement; element.style.opacity = opacity; // Update opacity } }, interval); } // Start the fade-out after 20 seconds setTimeout(() => { const div = document.getElementById('myDiv'); if (div) { fadeOutEffect(div, 1500); // 2000ms (2 seconds) fade-out duration } }, 15000); // 15 seconds </script>