-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping-cart.php
55 lines (54 loc) · 2.14 KB
/
shopping-cart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
$title = "Home - Project Store";
include("public-header.php");
?>
<?php
if(empty($_SESSION['cart_item'])){
echo '<div class="semRegistro">The cart is empty!</div>';
}else{
$total = 0;
?>
<table class="table table-striped table-responsive-lg">
<tbody>
<thead>
<tr class="tabela-geral">
<th>Product</th>
<th>Quantity</th>
<th>Un. Price</th>
</tr>
</thead>
<?php
foreach($_SESSION['cart_item'] as $cartProduct):
$total += $cartProduct['price'] * $cartProduct['quantity'];
?>
<tr>
<td>
<?php echo "<img class='figure-img img-fluid rounded' alt='".$cartProduct['name']."' title='".$cartProduct['name']."' src='".substr_replace($cartProduct['image'] ,"./inside",0,1)."' width='100x' height='100px'/>"?>
<?=$cartProduct['name']?>
</td>
<td>
<form action="update-shopping-cart.php" method="POST">
<div>
<input type="number" name="quantity" id="quantity" value="<?=$cartProduct['quantity']?>" class="form-control cart-input-resized">
<input type="hidden" value="<?=$cartProduct['id']?>" name="id">
<a href="remove-cart-item.php?id=<?=$cartProduct['id']?>" class="btn btn-outline-danger btn-sm botao-table"><i class="fa fa-minus-circle" aria-hidden="true"></i></a>
<button type="submit" class="btn btn-outline-primary btn-sm botao-table"><i class="fa fa-refresh" aria-hidden="true"></i></button>
</div>
</form>
</td>
<td>$: <?=$cartProduct['price']?></td>
</tr>
<?php
endforeach
?>
</tbody>
<tfoot>
<tr class="footer-tabela">
<td></td>
<td></td>
<td>Total: $<?=$total?></td>
</tr>
</tfoot>
</table>
<?php } ?>
<?php include("public-footer.php");?>