-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcart.php
128 lines (113 loc) · 5.61 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
require_once 'config/Config.php';
$user_function = new Config;
$counter = 1;
$total = array();
?>
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>My Cart</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" type="text/css"
rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<link href="css/custome-style.css" type="text/css" rel="stylesheet">
</head>
<body>
<?php include_once('header.php'); ?>
<div class="container-fluid mt-5">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<b> My Cart Detail </b>
</div>
<div class="card-body">
<div class="table-responsive-lg">
<table class="table v-set">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Product</th>
<th scope="col">Detail</th>
<th scope="col">Quantity</th>
<th scope="col">Price</th>
<th scope="col">Subtotal</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php if($cart_data){ foreach($cart_data as $cart_key => $cart_value){
$qty = $_SESSION['product_qty_cart'][$cart_key];
$field_val['p_number'] = $cart_value;
$get_cart = $user_function->select_where_cart("products", $field_val);
$subtotal = $qty * $get_cart['p_amount'];
$total[] = $subtotal;
?>
<tr>
<th scope="row"><?php echo $counter; $counter++; ?></th>
<td>
<img src="images/<?php echo $get_cart['p_image']; ?>" class="box-image-set-2">
</td>
<td><?php echo $get_cart['p_name']; ?></td>
<td><?php echo $qty; ?></td>
<td><?php echo $get_cart['p_amount']; ?></td>
<td><?php echo $subtotal; ?></td>
<td>
<button class="btn btn-sm btn-danger rm-val" data-dataval="<?php echo $cart_key; ?>">
<span><i class="far fa-trash-alt"></i></span>
<span>Remove</span>
</button>
</td>
</tr>
<?php }}else{ echo "<tr><td colspan='7'><h1 class='text-center' >Cart is Empty</h1></td></tr>"; } ?>
</tbody>
<tfoot>
<tr>
<td colspan="7"><b> Total Amount :: <?php echo @array_sum($total); ?> </b> </td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click', 'button.rm-val', function(){
var rm_val = $(this).data('dataval');
if(rm_val == ''){
alert('Data Value Not Found');
}
else{
$.ajax({
type: "POST",
url: "ajax/cart-process.php",
data: { 'rm_val' : rm_val },
success: function (response) {
var get_val = JSON.parse(response);
if(get_val.status == 102){
console.log(get_val.msg);
location.reload();
}
else{
console.log(get_val.msg);
}
}
});
}
});
});
</script>
</body>
</html>