Aggiunta controllo StockQuantity (prevenire ordini con prodotti esauriti)

This commit is contained in:
2026-04-13 13:40:44 +02:00
parent 5684731241
commit 63f6c21e02
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -54,7 +54,11 @@ if ($stmt = $conn->prepare($sql)) {
<p><strong>Descrizione:</strong> <?php echo htmlspecialchars($product['Description']); ?></p>
<p><strong>Prezzo:</strong> €<?php echo htmlspecialchars($product['Price']); ?></p>
<p><strong>Quantità disponibile:</strong> <?php echo htmlspecialchars($product['StockQuantity']); ?></p>
<button onclick="addToCart(<?php echo $product['ProductID']; ?>, '<?php echo htmlspecialchars($product['ProductName']); ?>', <?php echo $product['Price']; ?>)" style="padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Aggiungi al carrello</button>
<?php if ($product['StockQuantity'] > 0): ?>
<button onclick="addToCart(<?php echo $product['ProductID']; ?>, '<?php echo htmlspecialchars($product['ProductName']); ?>', <?php echo $product['Price']; ?>)" style="padding: 10px 20px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">Aggiungi al carrello</button>
<?php else: ?>
<button disabled style="padding: 10px 20px; background-color: #ccc; color: white; border: none; border-radius: 4px; cursor: not-allowed;">Esaurito</button>
<?php endif; ?>
</div>
</div>
<?php else: ?>