fetch( "SELECT * FROM products WHERE product_id = :id AND is_active = 1", ['id' => $productId] ); if (!$product) { header('Location: /shop.php'); exit; } $pageTitle = $product['name'] . " - Tom's Java Jive"; $pageDescription = truncate(strip_tags($product['description']), 160); // Get product reviews $reviews = db()->fetchAll( "SELECT * FROM reviews WHERE product_id = :id AND is_approved = 1 ORDER BY created_at DESC LIMIT 10", ['id' => $productId] ); $avgRating = 0; $reviewCount = count($reviews); if ($reviewCount > 0) { $avgRating = array_sum(array_column($reviews, 'rating')) / $reviewCount; } // Get related products $relatedProducts = db()->fetchAll( "SELECT * FROM products WHERE category = :category AND product_id != :id AND is_active = 1 LIMIT 4", ['category' => $product['category'], 'id' => $productId] ); $images = json_decode($product['images'] ?? '[]', true); $mainImage = !empty($images) ? $images[0] : '/assets/images/placeholder-product.svg'; $salePrice = $product['sale_price']; $price = $product['price']; $inStock = $product['stock'] > 0; require_once __DIR__ . '/includes/header.php'; ?>
<?= htmlspecialchars($product['name']) ?>
1): ?>
$img): ?> Product image <?= $index + 1 ?>

0): ?>
( reviews)
Save %

In Stock - Only left! Out of Stock

Description

Product Details

SKU
Weight oz
Category

Customer Reviews

Verified Purchase

No reviews yet. Be the first to review this product!

Related Products