-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmycart.php
246 lines (211 loc) · 11 KB
/
mycart.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
define('MYSITE', true);
include 'db/dbconnect.php';
$title = 'Main';
$css_directory = 'css/main.min.css';
$css_directory2 = 'css/main.min.css.map';
include 'includes/header.php';
include 'includes/navbar.php';
?>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12 mt-4">
<?php
//Alert OR Error Message:
if (isset($_SESSION['removesuccess'])) {
echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Success! </strong> ' . $_SESSION['removesuccess'] . '
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
unset($_SESSION['removesuccess']);
} elseif (isset($_SESSION['removeunsuccess'])) {
echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Oops! </strong> ' . $_SESSION['removeunsuccess'] . '
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
unset($_SESSION['removeunsuccess']);
}
?>
<div class="text-center border rounded bg-light my-4">
<h4>CART</h4>
</div>
</div>
<?php
if (!isset($_SESSION['cart']) || $_SESSION['cart'] != true) {
?>
<div class="container-fluid mt-5">
<div class="row align-self-center">
<div class="col-md-12">
<div class="card" style="border:none;">
<!-- <div class="card-header">
<h5>Cart</h5>
</div> -->
<div class="card-body">
<div class="col-sm-12 empty-cart-cls text-center">
<!-- <img src="https://i.imgur.com/dCdflKN.png" width="130" height="130" class="img-fluid mb-4 mr-3"> -->
<img src="img/EMPTY_CART.png" width="130" height="130" class="img-fluid mb-4 mr-3">
<h3><strong>Your Cart is Empty</strong></h3>
<h5 class="text-secondary">You will find a lot of interesting services on our "Service" page :)</h5>
<a href="index.php" class="btn btn-c1-1 cart-btn-transform m-3" data-abc="true">continue shopping</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
} else {
?>
<div class="col-lg-9">
<table class="table">
<thead class="thead-light text-center">
<tr>
<th scope="col">#</th>
<th scope="col">Service</th>
<th scope="col">Service Provider</th>
<th scope="col">Price</th>
<th scope="col">Quantity</th>
<th scope="col">Total</th>
<th scope="col">Operation</th>
</tr>
</thead>
<tbody class="text-center">
<?php
foreach ($_SESSION['cart'] as $key => $value) {
$sr = $key + 1;
?>
<tr>
<th scope="row"><?php echo $sr; ?></th>
<td><?php echo $value['service_title']; ?></td>
<td><?php echo $value['sp_name']; ?></td>
<td>
<small>₹</small><?php echo $value['price']; ?>
<input type="hidden" class="iprice" value="<?php echo $value['price']; ?>">
</td>
<!-- quantity -->
<form action="manage_cart.php" method="post">
<td><input type="number" class="text-center iquantity" name="Mod_Quantity" onchange="this.form.submit();" value="<?php echo $value['quantity']; ?>" min="1" max="20" step="1" oninput="validity.valid||(value='');"></td>
<input type="hidden" name="service_title" value="<?php echo $value['service_title']; ?>">
</form>
<!-- line Total -->
<td class="itotal"></td>
<!-- remove button -->
<td>
<form action="manage_cart.php" method="post">
<button class="btn btn-sm btn-outline-danger" name="remove_service">Remove</button>
<input type="hidden" name="service_title" value="<?php echo $value['service_title']; ?>">
</form>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="col-lg-3">
<div class="border bg-light rounded p-4">
<h4>Grand Total:</h4>
<div class="text-right">
<h6 style="display:inline-block;">₹</h6>
<h5 style="display:inline-block;" id="gtotal"></h5>
<h5 style="display:inline-block;" id="">/-</h5>
</div>
<?php
if (isset($_SESSION['cart']) && count($_SESSION['cart']) > 0) {
?>
<form action="order.php" method="post">
<div class="form-group">
<label>Full Name</label>
<input type="text" class="form-control" id="fullname" required>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="tel" class="form-control" required pattern="^[0-9-+\s()]{10}" name="phone" aria-describedby="phoneFeedback" data-for="phoneNumber">
</div>
<div class="form-group">
<label for="phone">Address</label>
<textarea name="address" id="address" cols="25" rows="3" required></textarea>
</div>
<div class="form-group">
<label>Pincode</label>
<input type="text" class="form-control" pattern="\d{6}" name="pincode" id="pincode" required>
</div>
<div class="form-group">
<label>Service Date:-</label>
<input type="datetime-local" class="form-control" name="due_date" id="due_date" required>
<small class="text-secondary">which DATE & TIME you want a service</small>
<div class="invalid-feedback">
<p id="error-message"></p>
</div>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="pay_mode" id="exampleRadios1" value="COD" checked>
<label class="form-check-label" for="exampleRadios1">
Cash On Delivery
</label>
</div>
<!-- <div class="form-check">
<input class="form-check-input" type="radio" name="pay_mode" id="exampleRadios2" value="Gpay">
<label class="form-check-label" for="exampleRadios2">
GPay
</label>
</div> -->
<br>
<button class="btn btn-primary btn-block" name="order">Make Order</button>
</form>
<?php
}
?>
</div>
</div>
</div>
</div>
<?php
//first session cart start che k nai te check krti vakhate else loop no end
}
?>
<script>
var gt = 0;
var iprice = document.getElementsByClassName('iprice');
var iquantity = document.getElementsByClassName('iquantity');
var itotal = document.getElementsByClassName('itotal');
var gtotal = document.getElementById('gtotal');
function subTotal() {
gt = 0;
for (i = 0; i < iprice.length; i++) {
itotal[i].innerText = (iprice[i].value) * (iquantity[i].value);
gt = gt + (iprice[i].value) * (iquantity[i].value);
var myVariable = gt;
localStorage.setItem("myVar", myVariable);
}
//print grand total
gtotal.innerText = gt;
}
subTotal();
</script>
<!-- date time validation -->
<script>
const datetimeInput = document.getElementById("due_date");
const errorMessage = document.getElementById("error-message");
datetimeInput.addEventListener("input", function() {
const selectedDatetime = new Date(datetimeInput.value);
const now = new Date();
if (selectedDatetime < now) {
errorMessage.textContent = "Please select a future date and time.";
datetimeInput.setCustomValidity("Please select a future date and time.");
} else {
errorMessage.textContent = "";
datetimeInput.setCustomValidity("");
}
});
</script>
<?php
include 'includes/footer.php';
// include 'includes/navfooter.php';
?>