-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewWishlist.php
286 lines (225 loc) · 10.6 KB
/
ViewWishlist.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
//Tell PHP to log errors
ini_set('log_errors', 'On');
//Tell PHP to not display errors
ini_set('display_errors', 'Off');
//Set error_reporting to E_ALL
ini_set('error_reporting', E_ALL );
include '_dbConnect.php';
// Start the session
session_start();
if(!$_SESSION['uname'])
{
$_SESSION["ViewWishlistAlert"] = true;
header("Location:index.php");
}
$uid = $_GET['uid'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Wishlist</title>
<!-- Tab Icon -->
<link rel="icon" href="assests/images/logo.png" type="image/icon type">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
<!-- CSS STYLE SHEETS -->
<link rel="stylesheet" href="assests/css/style.css">
<link rel="stylesheet" href="assests/css/Product.css">
</head>
<body>
<!-- header section -->
<header id="topheader" style="background:black">
<?php include 'header.php'; ?>
<!-- ************************************************************************************************** -->
<?php
if($_SESSION['wishlistAdded'])
{
$_SESSION['wishlistAdded'] = false;
echo '<div class="alert text-center alert-success alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
Item added to your wishlist!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if($_SESSION['AlreadyWishlist'])
{
$_SESSION['AlreadyWishlist'] = false;
echo '<div class="alert text-center alert-warning alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
Item already exist in your Wishlist!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if($_SESSION['wishlistRemoved'])
{
$_SESSION['wishlistRemoved'] = false;
echo '<div class="alert text-center alert-success alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
Item removed from your Wishlist!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
if($_SESSION['wishlistRemovedAll'])
{
$_SESSION['wishlistRemovedAll'] = false;
echo '<div class="alert text-center alert-success alert-dismissible fade show mb-0" role="alert" style="z-index:1000;">
All Items removed from your Wishlist!
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
<!-- ************************************************************************************************** -->
<?php include 'login_signup.php'; ?>
<div id="cart-message"></div>
</header>
<!-- header section ends -->
<!-- ************************************************************************************************** -->
<main>
<?php
$sql = "select * from wishlist where uid='$uid'";
$result = mysqli_query($conn,$sql);
$num_row = mysqli_num_rows($result);
if(!$num_row)
{
echo '<div align="center" style="margin-top:220px;"><img src="assests/images/empty_wishlist.png" alt="empty wishlist" style="width:50%" class="img-fluid" ></div>';
}
if($num_row) :
?>
<h1 class="text-center mb-5" style="font-size:3rem;margin-top:220px;color:var(--gold);">Wishlist <i class="fas fa-heart"></i> </h1>
<a href="RemoveWishlist.php?uid=<?= $uid?>" class="bg-danger text-white px-3 py-3" onclick="return confirm('Are you sure want to remove all items?');"><i class="fas fa-trash"></i> Clear Wishlist</a>
<section class="py-5">
<div class="container">
<div class="product-items">
<?php
while ($roww = mysqli_fetch_assoc($result)):
$pid = $roww['pid'];
$sqll = "select * from products where pid='$pid'";
$resultt = mysqli_query($conn,$sqll);
$rowww = mysqli_fetch_assoc($resultt);
$uid = $_SESSION['uid'];
?>
<div class="product">
<div class="product-content">
<div class="product-img">
<img src=" <?=$rowww["photo"]?> " alt="product image">
</div>
<div class="product-btns " style="align-items: center;">
<button type="button" class="btn-cart">
<span><a href="RemoveWishlist.php?pid=<?=$rowww["pid"]?>" class="text-white" onclick="return confirm('Are you sure want to remove this item?');"><i class="fas fa-trash-alt"></i></a></span>
</button>
<?php $discount = $rowww["pprice"] - (($rowww["pprice"]*$rowww["offer"])/100);
$discount = intval($discount); ?>
<form action="" class="form-submit">
<input type="hidden" class="form-control pqty" value="1">
<input type="hidden" class="pid" value=" <?=$rowww["pid"]?> ">
<input type="hidden" class="pname" value=" <?=$rowww["pname"]?> ">
<input type="hidden" class="pprice" value=" <?=$discount?> ">
<input type="hidden" class="pimage" value=" <?=$rowww["photo"]?> ">
<a href="cart.php?uid= <?=$uid?> "><button class="btn-buy addtomycart"><span><i class="fas fa-shopping-cart"></i></span></button></a>
</form>
<button type="button" class="btn-wishlist">
<span><a href="Product.php?pid=<?= $rowww["pid"] ?>" class="text-dark"><i
class="fas fa-eye"></i></a></span>
</button>
</div>
</div>
<div class="product-info">
<div class="product-info-top">
<h2 class="sm-title">Rating</h2>
<div class="rating">
<?php for($i=0; $i<$rowww["rating"]; $i++) {
echo '<span><i class="fas fa-star"></i></span>'; }
for($i=0; $i<5-$rowww["rating"]; $i++) {
echo '<span><i class="far fa-star"></i></span>'; } ?>
</div>
</div>
<a class="product-name"> <?= $rowww["pname"] ?> </a>
<?php
if($rowww["offer"])
{
$discount = $rowww["pprice"] - (($rowww["pprice"]*$rowww["offer"])/100);
$discount = intval($discount);
echo'
<p class="product-price-strike"> INR '. number_format($rowww["pprice"]) .'/-</p>
<p class="product-price"> INR '. number_format($discount) .'/-</p>';
}
else
{
echo '<p class="product-price"> INR '. number_format($rowww["pprice"]) .'/-</p>';
}
?>
</div>
<?php
if($rowww["offer"]) { echo'
<div class="off-info">
<h2 class="sm-title">25% off</h2>
</div>'; }
?>
</div>
<?php endwhile; ?>
</div>
</div>
</section>
<?php endif; ?>
<!-- ************************************************************************************************** -->
<!-- footer section -->
<?php include 'footer.php'; ?>
</main>
<!-- My JS file -->
<script src="assests/js/main.js"></script>
<!-- Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ" crossorigin="anonymous">
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.min.js'></script>
<script type="text/javascript">
$(document).ready(function() {
// Send product details in the server
$(".addtomycart").click(function(e) {
e.preventDefault();
var $form = $(this).closest(".form-submit");
var pid = $form.find(".pid").val();
var pname = $form.find(".pname").val();
var pprice = $form.find(".pprice").val();
var pimage = $form.find(".pimage").val();
var pqty = $form.find(".pqty").val();
$.ajax({
url: 'action.php',
method: 'post',
data: {
pid: pid,
pname: pname,
pprice: pprice,
pqty: pqty,
pimage: pimage,
},
success: function(response) {
$("#cart-message").html(response);
window.scrollTo(0, 0);
load_cart_item_number();
}
});
});
// Load total no.of items added in the cart and display in the navbar
load_cart_item_number();
function load_cart_item_number() {
$.ajax({
url: 'action.php',
method: 'get',
data: {
cartItem: "cart_item"
},
success: function(response) {
$("#cart-item").html(response);
}
});
}
});
</script>
</body>
</html>