-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.php
82 lines (66 loc) · 3.21 KB
/
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
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
<?php
include("includes/header.php");
?>
<div id="content">
<div class="post">
<h2 class="title"><a href="#">Cart</a></h2>
<p class="meta"></p>
<div class="entry">
<form action="addtocart.php" method="post">
<table class="cart" cellspacing="0" border="0" width="100%">
<tr align="center">
<th width="7%">No</th>
<th width="30%">Name</th>
<th width="20%">Image</th>
<th width="15%">Qty</th>
<th width="10%">Price</th>
<th width="10%">Rate</th>
<th width="7%">Remove</th>
</tr>
<?php
$count = 1;
$total = 0;
if (isset($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $id => $val) {
$rate = $val['qty'] * $val['price'];
$total = $total + $rate;
echo '<tr>
<td>' . $count . '</td>
<td>' . $val['nm'] . '</td>
<td><img src="' . $val['img'] . '" width="80" height="60"></td>
<td><input type="number" min="1" value="' . $val['qty'] . '" style="width: 50px" name="' . $id . '"></td>
<td>' . $val['price'] . '</td>
<td>' . $rate . '</td>
<td><a style="color: red;text-decoration:none;" href="addtocart.php?id=' . $id . '">X</a></td>
</tr>';
$count++;
}
}
?>
<tr style="font-weight: bold;">
<td colspan="5">Total : </td>
<td colspan="2">Rs. <?php echo $total; ?></td>
</tr>
</table>
<div align="center" style="margin-top: 20px">
<input type="submit" value="Re-calculate" class="btn_refresh">
<?php
// Constructing the link with individual item details
$order_details_link = 'order.php?total='.$total;
// Adding each item's name, quantity, and price as URL parameters
if (isset($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $id => $val) {
$order_details_link .= '&item_' . $id . '_name=' . urlencode($val['nm']) . '&item_' . $id . '_qty=' . $val['qty'] . '&item_' . $id . '_price=' . $val['price'];
}
}
// Echoing the modified link
echo '<a href="' . $order_details_link . '" name="button" style="font-family: open sans;" style="margin-left: 10px">Confirm & Submit Order</a>';
?>
</div>
</form>
</div>
</div>
</div><!-- end #content -->
<?php
include("includes/footer.php");
?>