mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 14:52:04 +00:00
Aggiunta controllo StockQuantity (prevenire ordini con prodotti esauriti)
This commit is contained in:
@@ -41,7 +41,11 @@ if ($result === false) {
|
|||||||
<a href="product.php?id=<?php echo $row['ProductID']; ?>"><div class="img-square"><img src="img/<?php echo htmlspecialchars($row['ImagePath']); ?>" alt="Immagine prodotto"></div></a>
|
<a href="product.php?id=<?php echo $row['ProductID']; ?>"><div class="img-square"><img src="img/<?php echo htmlspecialchars($row['ImagePath']); ?>" alt="Immagine prodotto"></div></a>
|
||||||
<h3><?php echo "<a href='product.php?id=" . $row['ProductID'] . "'>" . htmlspecialchars($row['ProductName']) . "</a>"; ?></h3>
|
<h3><?php echo "<a href='product.php?id=" . $row['ProductID'] . "'>" . htmlspecialchars($row['ProductName']) . "</a>"; ?></h3>
|
||||||
<p><?php echo htmlspecialchars($row['Price']); ?>€</p>
|
<p><?php echo htmlspecialchars($row['Price']); ?>€</p>
|
||||||
|
<?php if ($row['StockQuantity'] > 0): ?>
|
||||||
<button onclick="addToCart(<?php echo $row['ProductID']; ?>, '<?php echo htmlspecialchars($row['ProductName']); ?>', <?php echo $row['Price']; ?>)">Aggiungi al carrello</button>
|
<button onclick="addToCart(<?php echo $row['ProductID']; ?>, '<?php echo htmlspecialchars($row['ProductName']); ?>', <?php echo $row['Price']; ?>)">Aggiungi al carrello</button>
|
||||||
|
<?php else: ?>
|
||||||
|
<button disabled style="background-color: #ccc; cursor: not-allowed;">Esaurito</button>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -54,7 +54,11 @@ if ($stmt = $conn->prepare($sql)) {
|
|||||||
<p><strong>Descrizione:</strong> <?php echo htmlspecialchars($product['Description']); ?></p>
|
<p><strong>Descrizione:</strong> <?php echo htmlspecialchars($product['Description']); ?></p>
|
||||||
<p><strong>Prezzo:</strong> €<?php echo htmlspecialchars($product['Price']); ?></p>
|
<p><strong>Prezzo:</strong> €<?php echo htmlspecialchars($product['Price']); ?></p>
|
||||||
<p><strong>Quantità disponibile:</strong> <?php echo htmlspecialchars($product['StockQuantity']); ?></p>
|
<p><strong>Quantità disponibile:</strong> <?php echo htmlspecialchars($product['StockQuantity']); ?></p>
|
||||||
|
<?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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user