41 lines
1.7 KiB
PHP
41 lines
1.7 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/layout.php';
|
|
|
|
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
$product = $id ? get_product($id) : null;
|
|
|
|
if (!$product) {
|
|
flash_set('warning', 'Product not found.');
|
|
header('Location: /shop.php');
|
|
exit;
|
|
}
|
|
|
|
render_header($product['name'] . ' - E-SO9', 'shop');
|
|
?>
|
|
<main class="container my-5">
|
|
<div class="row g-4">
|
|
<div class="col-lg-6">
|
|
<img src="<?= e($product['image_url'] ?: product_image_data($product['name'])) ?>" class="img-fluid rounded" alt="<?= e($product['name']) ?>" width="800" height="600" />
|
|
</div>
|
|
<div class="col-lg-6">
|
|
<div class="text-muted small mb-2"><?= e($product['category_name'] ?? 'General') ?></div>
|
|
<h1 class="h3 mb-3"><?= e($product['name']) ?></h1>
|
|
<p class="text-muted mb-3"><?= e($product['description']) ?></p>
|
|
<div class="d-flex align-items-center gap-3 mb-4">
|
|
<span class="h4 mb-0"><?= e(format_price((float) $product['price'])) ?></span>
|
|
<span class="badge badge-soft">Rating <?= e((string) $product['rating']) ?></span>
|
|
<span class="text-muted small">Stock <?= e((string) $product['stock']) ?></span>
|
|
</div>
|
|
<form method="post" action="/cart.php" class="d-flex gap-2">
|
|
<input type="hidden" name="product_id" value="<?= e((string) $product['id']) ?>" />
|
|
<input type="number" name="quantity" class="form-control" min="1" max="<?= e((string) $product['stock']) ?>" value="1" />
|
|
<button class="btn btn-primary" type="submit">Add to cart</button>
|
|
</form>
|
|
<div class="admin-note mt-4">Demo checkout only. Orders are stored locally for the admin view.</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<?php render_footer(); ?>
|