-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewCart.php
More file actions
105 lines (103 loc) · 3.33 KB
/
ViewCart.php
File metadata and controls
105 lines (103 loc) · 3.33 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
include_once("Connection.php");
if(!isset($_SESSION['admin']))
{
echo "<script>alert('You must be login to see your cart')</script>";
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
else
{
?>
<link rel="stylesheet" href="css/bootstrap.min.css">
<?php
//session_start();
$cart = (isset($_SESSION['cart']))? $_SESSION['cart']: [];
?>
<script language="JavaScript">
function deleteConfirm() {
if (confirm("Are you sure to delete!")) {
return true;
} else {
return false;
}
}
</script>
<H1><B>MY CART</B></H1>
<?php
if($cart!=[])
{
?>
<table id="tableproduct" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th><strong>Product ID</strong></th>
<th><strong>Product Name</strong></th>
<th><strong>Image</strong></th>
<th><strong>Quantity</strong></th>
<th><strong>Price</strong></th>
<th><strong>Unit Price</strong></th>
<th><strong>Delete</strong></th>
</tr>
</thead>
<tbody>
<?php
$total= 0;
?>
<?php foreach($cart as $key => $value){
$total += ($value['price'] * $value['quantity']);
?>
<tr>
<td><?php echo $key++ ?></td>
<td><?php echo $value['name']?></td>
<td align='center' class='cotNutChucNang'>
<img src='product-imgs/<?php echo $value['image'] ?>' border='0' width="100" height="100" />
</td>
<form method="GET" action="CartFunction.php">
<td>
<input type="hidden" name="action" value="update">
<input type="hidden" name='ma' value="<?php echo $value['id'] ?>">
<input type="number" size="4" name="quantity" value="<?php echo $value['quantity']?>">
<button type="submit" name="buttonupdate" id="buttonupdate" id="buttonup">Update Quantity</button>
</td>
</form>
<td>$<?php echo $value['price']?></td>
<td>$<?php echo $value['price']*$value['quantity']?>
</td>
<td align='center' class='cotNutChucNang'>
<a href="CartFunction.php?ma=<?php echo $value['id'] ?>&action=delete" onclick="return deleteConfirm()">
<img src='images/delete.png' border='0' /></a>
</td>
</tr>
<?php } ?>
<tr>
<td colspan="5" align="right">
<h3>TOTAL:</h3>
</td>
<td>
<h3 class="price"><b>$<?php echo Number_format($total);?></b></h3>
</td>
<td></td>
</tr>
</tbody>
</table>
<div class="container">
<div class="col-sm-5">
</div>
<div class="col-sm-7">
<!-- <form method="POST" action="?page=payment">
<button type="submit" name="btnOrder" class="btn btn-primary">ORDER PRODUCT</button>
</form> -->
<br>
</div>
</div>
<?php }
else {
echo "<script>alert('EMPTY CART! PLEASE ADD A PRODUCT TO CART!')</script>";
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
?>
<?php
}
include_once("Index/Payment.php");
include_once("Index/Category/Allproduct.php");
?>