-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatex.php
More file actions
218 lines (182 loc) · 6.5 KB
/
Copy pathcatex.php
File metadata and controls
218 lines (182 loc) · 6.5 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
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
<?php
session_start();
include "db/connections.php";
if (isset($_SESSION["u"])) {
$user = $_SESSION["u"]["id"];
$total = 0;
$shipping = 0;
?>
<!DOCTYPE html >
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nimsara Computers - Product Cart</title>
<link rel="icon" href="fevicone/favicon.ico">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
<style>
body {
background: linear-gradient(to right, #0056b3, #007bff);
color: #fff;
font-family: 'Arial', sans-serif;
}
.container {
margin: 20px auto;
max-width: 1200px;
padding: 20px;
}
.row {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.card {
border-radius: 10px;
border: none;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
background-color: #1e1e1e;
color: #fff;
margin-bottom: 20px;
text-align: center; /* Center text inside the card */
width: 100%; /* Ensure the card takes up full width within its column */
max-width: 500px; /* Limit the maximum width of the card */
}
.card-img-top {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
height: 200px;
object-fit: cover;
}
.card-body {
padding: 20px;
}
.summary-card {
background-color: #343a40;
padding: 20px;
border-radius: 10px;
text-align: center; /* Center text in the summary card */
margin-top: 20px;
}
.summary-card h5 {
margin-bottom: 20px;
}
.btn {
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
}
.btn-outline-info {
color: #17a2b8;
border-color: #17a2b8;
}
.btn-outline-info:hover {
background-color: #17a2b8;
color: #fff;
}
.btn-info {
background-color: #17a2b8;
color: #fff;
}
.btn-info:hover {
background-color: #138496;
}
.btn-danger {
background-color: #dc3545;
color: #fff;
}
.btn-danger:hover {
background-color: #c82333;
}
.btn-primary {
background-color: #007bff;
color: #fff;
}
.btn-primary:hover {
background-color: #0056b3;
}
.text-primary {
color: #007bff;
}
.text-danger {
color: #dc3545;
}
.text-success {
color: #28a745;
}
.text-center {
text-align: center;
}
</style>
</head>
<body class="main-body">
<?php include "navbars.php"; ?>
<div class="container">
<?php
$cart_rs = Database::search("SELECT * FROM `cart` WHERE `user_id`='" . $user . "'");
$cart_num = $cart_rs->num_rows;
if ($cart_num == 0) {
?>
<!-- Empty View -->
<div class="text-center">
<div class="alert alert-info fs-3 fw-bold">
You have no items in your Cart yet.
</div>
<a href="home.php" class="btn btn-outline-info fs-3 fw-bold">Start Shopping</a>
</div>
<?php
} else {
for ($x = 0; $x < $cart_num; $x++) {
$cart_data = $cart_rs->fetch_assoc();
$product_rs = Database::search("SELECT * FROM `products` INNER JOIN `product_images` ON products.id = product_images.product_id WHERE products.id = '" . $cart_data["product_id"] . "'");
$product_data = $product_rs->fetch_assoc();
$total += $product_data["price"] * $cart_data["qty"];
$shipping += 250;
?>
<div class="row">
<div class="col-md-6">
<div class="card">
<img src="<?php echo $product_data["path"]; ?>" class="card-img-top" alt="<?php echo $product_data["title"]; ?>">
<div class="card-body">
<h5 class="card-title"><?php echo $product_data["title"]; ?></h5>
<p class="card-text"><?php echo $product_data["description"]; ?></p>
<p class="card-text">
<p class="card-text">Price: <span class="text-primary">Rs.<?php echo $product_data["price"]; ?>.00</span></p>
<p class="card-text">Quantity:
<input type="number" class="border border-2 border-secondary fs-4 fw-bold px-3" value="<?php echo $cart_data["qty"]; ?>" onchange="changeQTY(<?php echo $cart_data['id']; ?>);" id="qty_num-<?php echo $cart_data['id']; ?>">
</p>
<p class="card-text">Delivery Fee: <span class="text-danger"><?php echo $shipping; ?></span></p>
<a href="#" class="btn btn-info">Buy Now</a>
<a href="#" class="btn btn-danger ms-2" onclick="deleteFromCart(<?php echo $cart_data['id']; ?>);">Remove</a>
<p class="card-text mt-3">Requested Total: <span class="text-success"><?php echo ($product_data["price"] * $cart_data["qty"]) + 250; ?></span></p>
</div>
</div>
</div>
</div>
<?php
}
}
?>
<div class="summary-card mt-4">
<h5 class="text-center">Summary</h5>
<p class="card-text">Items (<?php echo $cart_num; ?>): <span class="text-primary" id="name">Rs. <?php echo $total; ?>.00</span></p>
<p class="card-text">Shipping: <span class="text-success">Rs. <?php echo $shipping; ?>.00</span></p>
<span class="fw-bold fs-2 text-white">Total <i class="bi bi-info-circle" id="price"> <?php echo $total + $shipping; ?></i></span>
<button class="btn btn-primary fs-5" onclick="checkuout();"><span class="fw-bold fs-3 text-white "><i class="bi bi-hand-index-thumb"></i>Check Out</span><button>
</div>
</div>
<?php include 'main footer.php'; ?>
<script src="script.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="https://www.payhere.lk/lib/payhere.js"></script>
<script src="swalw2.js"></script>
<script src="swalw.js"></script>
</body>
</html>
<?php
} else {
header("Location: indexlk.php");
}
?>