-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder-page.php
More file actions
198 lines (182 loc) · 8.57 KB
/
Order-page.php
File metadata and controls
198 lines (182 loc) · 8.57 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
<?php
// Include the database connection
include("database.php");
session_start(); // Start the session to access session variables
// Check if the user is logged in
if (!isset($_SESSION['username'])) {
header("Location: index.php");
exit();
}
// Fetch the username from the session
$username = $_SESSION['username'];
// Retrieve the product ID from the URL and validate it
$productId = isset($_GET['productId']) ? intval($_GET['productId']) : 0;
// Fetch product details from the database
$product = null;
if ($productId > 0) {
$stmt = $connect->prepare("SELECT * FROM products WHERE ProductID = ? LIMIT 1");
$stmt->bind_param("i", $productId);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$product = $result->fetch_assoc();
} else {
// Handle invalid product ID (redirect or show an error)
header("Location: homepage.php?error=invalidProduct");
exit();
}
} else {
// Handle missing product ID (redirect or show an error)
header("Location: homepage.php?error=missingProduct");
exit();
}
$isCustomizable = $product['Customizable'] == 1;
// Size mapping array
$sizeMapping = [
'XS' => 'Extra Small',
'S' => 'Small',
'M' => 'Medium',
'L' => 'Large',
'XL' => 'Extra Large',
// Add more sizes as necessary
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Page</title>
<link rel="stylesheet" href="Order-page.css">
<link rel="shortcut icon" href="https://res.cloudinary.com/drkmgpcad/image/upload/v1726841328/rahjpg3k7mdtnow4ttux.png" type="image/x-icon">
<link href="https://fonts.googleapis.com/css2?family=Beau+Rivage&display=swap" rel="stylesheet">
</head>
<body>
<header>
<div>
<a class="logo-div" href="homepage.php" target="_self" onclick="showLoadingScreen('Loading...')">
<img src="https://res.cloudinary.com/drkmgpcad/image/upload/v1726841328/rahjpg3k7mdtnow4ttux.png" alt="Logo">
<h1>Happy Ending</h1>
</a>
</div>
<div id="search-container">
<input type="text" id="search-query" placeholder="Search..." oninput="searchProducts()">
<div id="search-results" class="search-results"></div>
</div>
<!-- Navigation Bar -->
<div class="navbar">
<div class="icons">
<span class="cart-icon"><a href=""><img src="Images/cart.png" alt="Cart" id="cartIcon"></a></span>
<div class="profile-dropdown">
<span class="profile-icon"><img src="Images/userIcon.png" alt="User Icon" id="userIcon"></span>
<span class="username"><a href="myaccount.php" id="usernameLink"><?php echo htmlspecialchars($username); ?></a></span>
<ul class="dropdown-menu" id="dropdownMenu">
<li><a href="myaccount.php">My Account</a></li>
<li class="divider"></li>
<li><a href="#">My Purchases</a></li>
<li class="divider"></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div>
</div>
</div>
</header>
<main>
<?php if ($product): ?>
<div class="product-container">
<div class="product-card">
<div class="product-images">
<div class="main-image">
<img src="<?php echo htmlspecialchars($product['ImageUrl']); ?>" alt="<?php echo htmlspecialchars($product['ProductName']); ?>">
</div>
<div class="sub-images">
<?php if (!empty($product['ImageUrl1'])): ?>
<div class="sub-image">
<img src="<?php echo htmlspecialchars($product['ImageUrl1']); ?>" alt="Additional Image 1">
</div>
<?php endif; ?>
<?php if (!empty($product['ImageUrl2'])): ?>
<div class="sub-image">
<img src="<?php echo htmlspecialchars($product['ImageUrl2']); ?>" alt="Additional Image 2">
</div>
<?php endif; ?>
</div>
<div class="description">
<h3>Description:</h3>
<p id="productDescription">
<?php echo htmlspecialchars($product['Description']); ?>
</p>
</div>
</div>
<div class="product-info">
<h2><?php echo htmlspecialchars($product['ProductName']); ?></h2>
<hr width="400vw">
<div class="price">
<span class="current-price">₱ <?php echo htmlspecialchars($product['Price']); ?></span>
</div>
<div class="links">
<a href="javascript:void(0);" class="size-link" onclick="openModal()">Size Chart</a>
<?php if ($isCustomizable): ?>
<a href="customize.php?productId=<?php echo htmlspecialchars($product['ProductID']); ?>" class="customize-link">Customize here</a>
<?php else: ?>
<a href="javascript:void(0);" class="customize-link" title="This product is not customizable.">Customize here</a>
<?php endif; ?>
</div>
<div class="size-color-selector">
<div class="size-color-item">
<span>Size:</span>
<span class="size-value">
<?php
$sizeCode = htmlspecialchars($product['size']);
echo isset($sizeMapping[$sizeCode]) ? $sizeMapping[$sizeCode] : $sizeCode;
?>
</span>
</div>
<div class="size-color-item">
<span>Color:</span> <span class="color-value"><?php echo htmlspecialchars($product['color']); ?></span>
</div>
</div>
<div class="stock-info">
<strong>Available Stock:</strong> <span class="stock-amount"><?php echo htmlspecialchars($product['Stock']); ?></span>
</div>
<div class="quantity-selector">
<label for="quantity">Quantity</label>
<div class="quantity-controls">
<input type="number" id="quantity" min="1" max="<?php echo htmlspecialchars($product['Stock']); ?>" value="1" class="quantity-input">
</div>
</div>
<div class="buttons">
<button class="checkout-btn">Checkout</button>
<button class="add-to-cart-btn">Add to cart</button>
</div>
</div>
</div>
</div>
<?php else: ?>
<p>Product not found.</p>
<?php endif; ?>
</main>
<div id="sizeChartModal" class="size-modal">
<div class="modal-chart">
<span class="close-button" onclick="closeModal()">×</span>
<?php
// Determine the image based on product type
$sizeChartImage = (isset($product['ProductType']) && $product['ProductType'] === 'Urn') ? 'https://res.cloudinary.com/drkmgpcad/image/upload/v1724236655/20240522_223149_0000_oil3uj.png' : 'https://res.cloudinary.com/drkmgpcad/image/upload/v1723987453/sample.jpg';
?>
<img src="<?php echo htmlspecialchars($sizeChartImage); ?>" alt="Size Chart" class="size-chart-image">
</div>
</div>
<footer>
<p class="copyright">© 2024 Happy Ending. All rights reserved.</p>
<nav>
<ul>
<li class="about-us"><a href="#" onclick="showLoadingScreen('Loading...')">ABOUT US</a></li>
<li><a href="www.facebook.com" target="_blank" onclick="showLoadingScreen('Loading...')"><img class="icons-picture" src="https://res.cloudinary.com/drkmgpcad/image/upload/v1724068194/angoienw2wu8c1aqdrge.png" alt="FB-logo"></a></li>
<li><a href="www.instagram.com" target="_blank" onclick="showLoadingScreen('Loading...')"><img class="icons-picture" src="https://res.cloudinary.com/drkmgpcad/image/upload/v1726891138/zzzgspgokfq1sbc9sjmu.webp" alt="IG-logo"></a></li>
<li><a href="www.x.com" target="_blank" onclick="showLoadingScreen('Loading...')"><img class="icons-picture" src="https://res.cloudinary.com/drkmgpcad/image/upload/v1726890890/edvvrnyg1wewlm1onmzs.png" alt="X-logo"></a></li>
</ul>
</nav>
</footer>
<script src="Order-page.js"></script>
</body>
</html>