Server : LiteSpeed System : Linux in-mum-web1743.main-hosting.eu 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64 User : u993087259 ( 993087259) PHP Version : 8.2.29 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail Directory : /home/u993087259/domains/naturalsveda.in/public_html/ |
<?php
include "connection.php";
$product_id = $_GET['id'] ?? 1; // Default to 1 if no ID provided
$sql = "SELECT * FROM products WHERE id = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param("i", $product_id);
$stmt->execute();
$result = $stmt->get_result();
$product = $result->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!-- Title -->
<title>Natural's Veda</title>
<!-- Core Style CSS -->
<?php
include "Header-Script.php";
?>
</div>
<style>
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
#view-cart-popup img {
width: 40%;
}
</style>
</head>
<body>
<!-- Header Area Start -->
<?php
include "Header.php";
?>
<!-- Header Area End -->
<!-- Single Product Details Area Start -->
<section class="single_product_details_area d-flex align-items-center">
<div class="single_product_thumb clearfix">
<div class="product_thumbnail_slides owl-carousel">
<img src="https://www.naturalsveda.in/admin/assets/img/product-detail/<?php echo $product['largephoto']; ?>" alt="<?php echo $product['name']; ?>">
<img src="https://www.naturalsveda.in/admin/assets/img/product-detail/<?php echo $product['largephoto']; ?>"" alt="">
</div>
</div>
<div class="single_product_desc clearfix">
<span><span class="discount text-success"><?php echo $product['descount']; ?>% OFF</span></span>
<div class="product">
<h2><span class="product-info" data-name="<?php echo $product['name']; ?>" data-price="<?php echo $product['phone']; ?>"><?php echo $product['name']; ?></span></h2>
<p class="product-price"><span class="old-price"><?php echo nl2br(htmlspecialchars($product['cutprice'])); ?>₹</span> <?= $product['phone'] ?>₹</p>
<p class="product-desc"><?php echo htmlspecialchars($product['description']); ?></p>
<div class="row">
<div class="col-md-6 col-6">
<input type="number" class="form-control product-quantity qty-input" value="1" min="1">
</div>
<div class="col-md-6 col-6">
<button class="btn essence-btn add-to-cart" onclick="addToCart(this)" class="btn btn-primary">Add to Cart</button>
</div>
</div>
</div>
</div>
</section>
<!-- New Arrivals Area Start -->
<section class="new_arrivals_area section-padding-80 clearfix">
<div class="container">
<div class="row">
<div class="col-12">
<div class="section-heading text-center">
<h2>Related products</h2>
</div>
</div>
</div>
</div>
<?php
$sql = "SELECT * FROM products";
$result = $con->query($sql);
?>
<div class="container">
<div class="row">
<div class="col-12">
<div class="popular-products-slides owl-carousel">
<?php if ($result->num_rows > 0): ?>
<?php while ($product = $result->fetch_assoc()): ?>
<!-- Single Product -->
<div class="single-product-wrapper">
<!-- Product Image -->
<a href="product_detail?id=<?php echo $product['id']; ?>">
<div class="product-img">
<!-- Product Badge -->
<img src="https://www.naturalsveda.in/admin/assets/img/product/<?php echo $product['photo']; ?>" alt="<?php echo $product['name']; ?>">
</div>
<!-- Product Description -->
<div class="product-description">
<h6><?= $product['name'] ?></h6>
<p class='paragraph'><?php echo $product['description']; ?></p> <!-- Show short description -->
<p class="product-price">  <?= $product['phone'] ?>₹  <span class="old-price"><?php echo $product['cutprice']; ?>₹</span><span class="discount text-success"><?php echo $product['descount']; ?>% OFF</span></p>
<!-- Add to Cart -->
<div class="add-to-cart-btn input-group mb-3">
<input class="form-control product-quantity" type="number" id="qty<?= $row['id'] ?>" value="1" min="1">
<button class="btn essence-btn add-to-cart" onclick="addToCart('<?= addslashes($row['name']) ?>', <?= $row['phone'] ?>, 'qty<?= $row['id'] ?>')">Buy Now</button>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>No blog posts found.</p>
<?php endif; ?>
<?php $con->close(); ?>
</div>
</div>
</div>
</div>
</section>
<!-- New Arrivals Area End -->
<!-- <div id="view-cart-popup" style="
position: fixed;
top: 0;
right: 0;
color: white;
padding: 0;
border-radius: 8px;
font-weight: bold;
font-size: 16px;
display: none;
z-index: 9999;
animation: fadeInUp 0.5s ease;
">
<a href="cart.php" style="color: white; text-decoration: none;"><img src="https://naturalsveda.in/assets/img/icon/red-shopping-cart-icon-3d-design-online-retail.png" alt=""></a>
</div> -->
<br>
<!-- <a href="cart.php">Go to Cart</a> -->
<!-- Footer Area Start -->
<?php
include "Footer.php";
?>
<!-- Footer Area End -->
<?php
include "Footer-Script.php";
?>
<script>
function addToCart(button) {
const productDiv = button.closest('.product');
const span = productDiv.querySelector('.product-info');
const name = span.dataset.name;
const price = parseFloat(span.dataset.price);
const qtyInput = productDiv.querySelector('.qty-input');
const qty = parseInt(qtyInput.value);
if (qty < 1) return alert("Quantity must be at least 1");
let cart = JSON.parse(localStorage.getItem('cart') || '[]');
const existing = cart.find(item => item.name === name);
if (existing) {
existing.qty += qty;
} else {
cart.push({
name,
price,
qty
});
}
localStorage.setItem('cart', JSON.stringify(cart));
// Show animated "View Cart" popup
const popup = document.getElementById('view-cart-popup');
popup.style.display = 'block';
setTimeout(() => {
popup.style.display = 'none';
}, 3000000);
}
</script>
<!-- <script>
function addToCart(button) {
// Get parent .product element
const productDiv = button.closest('.product');
// Get product name and price from data attributes
const span = productDiv.querySelector('.product-info');
const name = span.dataset.name;
const price = parseFloat(span.dataset.price);
// Get quantity
const qtyInput = productDiv.querySelector('.qty-input');
const qty = parseInt(qtyInput.value);
if (qty < 1) return alert("Quantity must be at least 1");
// Get cart from localStorage
let cart = JSON.parse(localStorage.getItem('cart') || '[]');
// Check if product already in cart
const existing = cart.find(item => item.name === name);
if (existing) {
existing.qty += qty;
} else {
cart.push({
name,
price,
qty
});
}
localStorage.setItem('cart', JSON.stringify(cart));
alert(`<a href="cart.php">Go to Cart</a>`);
}
</script> -->
</body>
</html>