-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarthandler.php
More file actions
75 lines (66 loc) · 2.03 KB
/
carthandler.php
File metadata and controls
75 lines (66 loc) · 2.03 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
<?php
session_start();
include("config.php");
if(isset($_POST["add_to_cart"])){
if(isset ($_SESSION["shopingcart"])){
$item_array_id=array_column($_SESION["shopingcart"],"item_id");
if(!in_array($_GET["id"],$item_array_id)){
$count = count ($_SESSION["shopingcart"]);
$item_array_id = $_GET["C_id"];
$item_array_make =$_POST["hidden_name"];
$item_array_speed = $_POST["Hidden_price"];
$item_array_acceleration = $_POST["quantity"];
$_SESSION["shopingcart"][$count]=$item_array;
}
else{
echo '<script>alert("Item Alredy Added")</script>';
echo '<script>window.location="shopingcart.php"</script>';
}
}
else{
$item_array_id = $_GET["C_id"];
$item_array_make =$_POST["hidden_name"];
$item_array_speed = $_POST["Hidden_price"];
$item_array_acceleration = $_POST["quantity"];
$_SESSION["shopingcart"][0] = $item_array;
}
}
?>
<html>
<head>
</head>
<body>
<h3>Order Details</h3>
<div class="table_respomsive">
<table class="table table-bordered">
<tr>
<th width="40%">Item Name</th>
<th width="10%">Quantity</th>
<th width="20%">Price</th>
<th width="15%">Total</th>
<th width="5%">Action</th>
</tr>
<?php
if(!empty($_SESSION("shopincart"))){
$total = 0;
foreach($_SESSION["shopingcart"] as $keys => $values){
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td><?php echo $values["item_price"]; ?></td>
<td><?php echo number_format($values["item_quantity"] * $values["item_price"],2);?></td>
<td><a href="shopingcart.php?action=delete$id=<?php echo $values["item_id"];?> <span class="text-danger">Remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"]* $values["item_price"]);
}
}
?>
<tr>
<td colspan="3" align= "right">Total</td>
<td align="right">$ <?php echo number_format($total,2);?></td>
</tr>
</table>
</body>
</html>