|
1 | 1 | <?php include 'partials/header.php'; ?> |
2 | 2 |
|
3 | 3 | <main> |
4 | | - <h1><?= htmlspecialchars($product->name) ?></h1> |
5 | | - <p>Prix: <?= htmlspecialchars($product->price) ?> €</p> |
6 | | - <p>Description: <?= htmlspecialchars($product->description) ?></p> |
7 | | - <p>Catégorie(s): |
8 | | - <?php if (!empty($product->category_name)) { ?> |
9 | | - <?php if (is_array($product->category_name)) { ?> |
10 | | - <?= htmlspecialchars(implode(', ', $product->category_name)) ?> |
11 | | - <?php } else { ?> |
12 | | - <?= htmlspecialchars($product->category_name) ?> |
13 | | - <?php } ?> |
14 | | - <?php } else { ?> |
15 | | - Aucune catégorie trouvée |
16 | | - <?php } ?> |
17 | | - </p> |
| 4 | + <div class="product-page"> |
| 5 | + <h1><?= htmlspecialchars($product->name) ?></h1> |
18 | 6 |
|
19 | | - <?php if ($product->supplier_name && $product->supplier_phone && $product->supplier_email) { ?> |
20 | | - <p>Fournisseur: <?= htmlspecialchars($product->supplier_name) ?> |
21 | | - - <?= htmlspecialchars($product->supplier_email) ?> |
22 | | - - <?= htmlspecialchars($product->supplier_phone) ?> |
23 | | - </p> |
24 | | - <?php } ?> |
| 7 | + <div class="product-info"> |
| 8 | + <span class="label">Prix</span> <span><?= htmlspecialchars($product->price) ?> €</span> |
| 9 | + <span class="label">Description</span><span><?= htmlspecialchars($product->description) ?></span> |
| 10 | + <span class="label">Catégorie(s)</span><span> |
| 11 | + <?php if (!empty($product->category_name)): ?> |
| 12 | + <?= htmlspecialchars(is_array($product->category_name) ? implode(', ', $product->category_name) : $product->category_name) ?> |
| 13 | + <?php else: ?> |
| 14 | + Aucune catégorie trouvée |
| 15 | + <?php endif; ?> |
| 16 | + </span> |
| 17 | + <?php if ($product->supplier_name && $product->supplier_phone && $product->supplier_email): ?> |
| 18 | + <span class="label">Fournisseur</span> |
| 19 | + <span> |
| 20 | + <?= htmlspecialchars($product->supplier_name) ?> |
| 21 | + — <?= htmlspecialchars($product->supplier_email) ?> |
| 22 | + — <?= htmlspecialchars($product->supplier_phone) ?> |
| 23 | + </span> |
| 24 | + <?php endif; ?> |
| 25 | + </div> |
25 | 26 |
|
26 | | - <?php if ($inCartQuantity > 0) { ?> |
27 | | - <p style="color: green; font-weight: bold;"> |
28 | | - This product is already in your cart. (<?= (int) $inCartQuantity ?> total in cart) |
29 | | - </p> |
30 | | - <?php } ?> |
| 27 | + <?php if ($inCartQuantity > 0): ?> |
| 28 | + <p class="in-cart-notice">Already in your cart (<?= (int)$inCartQuantity ?> total)</p> |
| 29 | + <?php endif; ?> |
31 | 30 |
|
32 | | - <form method="POST" action="/cart"> |
33 | | - <input type="hidden" name="product_id" value="<?= (int) $product->id ?>"> |
34 | | - <input type="hidden" name="product_name" value="<?= htmlspecialchars($product->name, ENT_QUOTES) ?>"> |
35 | | - <input type="hidden" name="product_price" value="<?= htmlspecialchars($product->price, ENT_QUOTES) ?>"> |
36 | | - <input type="hidden" name="is_from_cart" value="False"> |
| 31 | + <form method="POST" action="/cart"> |
| 32 | + <input type="hidden" name="product_id" value="<?= (int)$product->id ?>"> |
| 33 | + <input type="hidden" name="product_name" value="<?= htmlspecialchars($product->name, ENT_QUOTES) ?>"> |
| 34 | + <input type="hidden" name="product_price" value="<?= htmlspecialchars($product->price, ENT_QUOTES) ?>"> |
| 35 | + <input type="hidden" name="is_from_cart" value="False"> |
37 | 36 |
|
38 | | - <?php if ($userId) { ?> |
39 | | - <?php if (!empty($slots)) { ?> |
40 | | - <h3>Personnalisez votre produit</h3> |
41 | | - |
42 | | - <?php foreach ($slots as $slot): ?> |
43 | | - <fieldset style="margin-bottom: 1rem; padding: 1rem; border: 1px solid #ddd; border-radius: 8px;"> |
44 | | - <legend> |
45 | | - <?= htmlspecialchars($slot->category_name) ?> |
46 | | - (<?= (int) $slot->min_select ?> à <?= (int) $slot->max_select ?>) |
47 | | - </legend> |
48 | | - |
49 | | - <?php for ($row = 0; $row < (int) $slot->max_select; $row++): ?> |
50 | | - <div style="margin-bottom: 0.75rem;"> |
51 | | - <select name="customization[<?= (int) $slot->id ?>][]" <?= $row < (int) $slot->min_select ? 'required' : '' ?>> |
| 37 | + <?php if ($userId): ?> |
| 38 | + <?php if (!empty($slots)): ?> |
| 39 | + <h3>Personnalisez votre produit</h3> |
| 40 | + <?php foreach ($slots as $slot): ?> |
| 41 | + <fieldset class="slot"> |
| 42 | + <legend> |
| 43 | + <?= htmlspecialchars($slot->category_name) ?> |
| 44 | + (<?= (int)$slot->min_select ?> à <?= (int)$slot->max_select ?>) |
| 45 | + </legend> |
| 46 | + <?php for ($row = 0; $row < (int)$slot->max_select; $row++): ?> |
| 47 | + <select name="customization[<?= (int)$slot->id ?>][]" <?= $row < (int)$slot->min_select ? 'required' : '' ?>> |
52 | 48 | <option value="">-- Select an option --</option> |
53 | 49 | <?php foreach ($slot->options as $option): ?> |
54 | | - <option value="<?= (int) $option->option_product_id ?>" <?= $row === 0 && !empty($option->is_default) ? 'selected' : '' ?>> |
| 50 | + <option value="<?= (int)$option->option_product_id ?>" <?= $row === 0 && !empty($option->is_default) ? 'selected' : '' ?>> |
55 | 51 | <?= htmlspecialchars($option->option_product_name) ?> |
56 | | - <?= ((float) $option->price_delta !== 0.0) ? ' (' . htmlspecialchars((string) $option->price_delta) . ' €)' : ' (free)' ?> |
| 52 | + <?= ((float)$option->price_delta !== 0.0) ? ' (' . htmlspecialchars((string)$option->price_delta) . ' €)' : ' (free)' ?> |
57 | 53 | </option> |
58 | 54 | <?php endforeach; ?> |
59 | 55 | </select> |
60 | | - </div> |
61 | | - <?php endfor; ?> |
62 | | - </fieldset> |
63 | | - <?php endforeach; ?> |
64 | | - <?php } ?> |
65 | | - |
66 | | - <button type="submit" name="action" value="add">Add to Cart</button> |
67 | | - <?php } else { ?> |
68 | | - <p style="color: red; font-weight: bold;">Please sign in to add this product to your cart.</p> |
69 | | - <?php } ?> |
70 | | - </form> |
| 56 | + <?php endfor; ?> |
| 57 | + </fieldset> |
| 58 | + <?php endforeach; ?> |
| 59 | + <?php endif; ?> |
| 60 | + <button type="submit" name="action" value="add" class="btn btn-pourpre">Add to Cart</button> |
| 61 | + <?php else: ?> |
| 62 | + <p>Please sign in to add this product to your cart.</p> |
| 63 | + <?php endif; ?> |
| 64 | + </form> |
| 65 | + </div> |
71 | 66 | </main> |
72 | 67 |
|
73 | 68 | <?php include 'partials/footer.php'; ?> |
0 commit comments