60 lines
2.2 KiB
PHP
60 lines
2.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
@date_default_timezone_set('UTC');
|
|
|
|
require_once __DIR__ . '/includes/data.php';
|
|
|
|
$lang = 'en';
|
|
$site = site_config($lang);
|
|
$productData = get_products($lang);
|
|
$productId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
$selected = null;
|
|
|
|
foreach ($productData as $product) {
|
|
if ($product['id'] === $productId) {
|
|
$selected = $product;
|
|
break;
|
|
}
|
|
}
|
|
|
|
$pageTitle = $selected ? $selected['name'] . ' | ' . $site['brand'] : 'Product Detail | ' . $site['brand'];
|
|
?>
|
|
<?php require __DIR__ . '/includes/header.php'; ?>
|
|
|
|
<main class="container my-5">
|
|
<?php if (!$selected): ?>
|
|
<div class="alert alert-warning">Product not found.</div>
|
|
<a class="btn btn-primary" href="/products.php">Back to products</a>
|
|
<?php else: ?>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<!-- Carousel -->
|
|
<div id="productCarousel" class="carousel slide" data-bs-ride="carousel">
|
|
<div class="carousel-inner">
|
|
<?php foreach ($selected['images'] as $index => $img): ?>
|
|
<div class="carousel-item <?= $index === 0 ? 'active' : '' ?>">
|
|
<img src="<?= htmlspecialchars($img) ?>" class="d-block w-100" alt="Product Image">
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<button class="carousel-control-prev" type="button" data-bs-target="#productCarousel" data-bs-slide="prev">
|
|
<span class="carousel-control-prev-icon bg-dark"></span>
|
|
</button>
|
|
<button class="carousel-control-next" type="button" data-bs-target="#productCarousel" data-bs-slide="next">
|
|
<span class="carousel-control-next-icon bg-dark"></span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h1><?= htmlspecialchars($selected['name']) ?></h1>
|
|
<p class="lead text-muted"><?= htmlspecialchars($selected['summary']) ?></p>
|
|
<p><?= htmlspecialchars($selected['details']) ?></p>
|
|
<a class="btn btn-lg btn-success" href="https://wa.me/<?= $site['whatsapp_number'] ?>?text=<?= urlencode($site['whatsapp_message']) ?>">
|
|
Contact on WhatsApp
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<?php require __DIR__ . '/includes/footer.php'; ?>
|