[EDIT] FILE: cart.php
<?php include('function.php'); include_once('includes/db.php'); $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; head( 'Spices & Dry Fruits Manufacturer in Delhi, Spices & Dry Fruits supplier in Delhi, best Spices & Dry Fruits producer in Delhi, best Spices & Dry Fruits supplier in inderpuri Delhi, best quality Spices & Dry Fruits supplier in delhi, Delhi best manufacturer & supplier of Spices & Dry Fruits.', 'Green Mounts offers a wide range of high-quality spices and dry fruits. Trusted leading manufacturer and supplier in delhi for all your culinary needs.', 'Spices & Dry Fruits Manufacturer in Delhi | Green Mounts', $url ); $ob = new database(); if (isset($_SESSION['logged_in_id'])) { $session_id = $_SESSION['logged_in_id']; }else{ $session_id = ""; } ?> <div class="page-path"> <div class="container"> <div class="breadcrumbs-inner"> <h1 class="path-title">Cart</h1> <ul> <li><a class="home-page-link" href="index.php">Home <i class="fal fa-angle-right"></i></a></li> <li><a class="current-page" href="#">Cart</a></li> </ul> </div> </div> </div> <div class="rts-cart-section"> <div class="container"> <h4 class="section-title">Product List</h4> <div class="row justify-content-between"> <div class="col-xl-7"> <div class="cart-table-area"> <table class="table table-bordered table-hover"> <thead class="thead-dark"> <tr> <th class="low1">Product</th> <th class="low7">Price</th> <th class="low7">Quantity</th> <th class="low7">Total</th> </tr> </thead> <tbody class="cart_details"> <?php $grandTotal = 0; $subTotal = 0; if(isset($_SESSION['user']) || isset($session_id)){ if($session_id){ $user = $session_id; $ob->query("SELECT * FROM cart WHERE user_id='$user'"); }else{ $user = $_SESSION['user']; $ob->query("SELECT * FROM cart WHERE user='$user'"); } if($ob->affected_rows() >= 1){ foreach($ob->rows() as $cart){ $qty = $cart['qty']; ?> <tr> <td> <?php $total = 0; $sizePrice = 0; $ob->query("SELECT * FROM size WHERE id='$cart[size]'"); if ($ob->affected_rows() >= 1) { foreach ($ob->rows() as $size) { $sizePrice = $size['price']; } } $ob->query("SELECT * FROM product WHERE id='$cart[product]'"); if ($ob->affected_rows() >= 1) { foreach ($ob->rows() as $product) { ?> <div class="d-flex align-items-center gap-2"> <img src="admin/<?php echo $product['image']; ?>" class="cartImg" alt="<?php echo $product['title']; ?>" /> <div class="d-flex flex-column align-items-start"> <?php echo $product['title']; ?> <span>Size: <?php echo $size['size']; ?></span> </div> </div> <?php } } ?> </td> <td> <?php $total = $product['price'] + $sizePrice; echo $total; ?> </td> <td> <input type="number" class="form-control updateQty" data-id="<?php echo $cart['id']; ?>" name="cart<?php echo $cart['id']; ?>" id="<?php echo $cart['id']; ?>" value="<?php echo $cart['qty']; ?>" /> </td> <td> <?php echo '₹ ' . $total * $cart['qty']; $subTotal = $subTotal + ($total * $cart['qty']); ?> </td> </tr> <?php } } } ?> </tbody> </table> </div> </div> <div class="col-xl-4"> <div class="checkout-box"> <span class="spend-shipping mb-4"> <i class="fal fa-truck"></i> <span class="price fw-6"> <?php $gst = 0; if ($subTotal > 1999) { } else { echo 'Add ₹ '. 1999 - $subTotal .'</span> more to'; } ?> Enjoy <span class="fw-6">Free Shipping.</span> </span> <div class="checkout-box-inner"> <div class="subtotal-area"> <span class="title">Subtotal</span> <span class="subtotal-price"><?php echo '₹ '. $subTotal; ?></span> </div> <div class="shipping-location"> <span class="shipping-to">Shipping to whole <span>India.</span> for free shipping shop over Rs 1999.</span> </div> <div class="total-area"> <span class="title">Total</span> <span class="total-price"><?php echo '₹ '. $subTotal; ?></span> </div> </div> <a href="checkout.php" class="procced-btn">Procced To Checkout</a> </div> </div> </div> </div> </div> <?php foter(); ?>
SAVE
CANCEL