-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayment.html
More file actions
515 lines (443 loc) · 24.7 KB
/
payment.html
File metadata and controls
515 lines (443 loc) · 24.7 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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkout - Elevate</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Header -->
<header>
<div class="container">
<div class="navbar">
<a href="index.html" class="logo"><img src="logo.1.png"></img></a>
<nav class="nav-links" id="navLinks">
<a href="index.html">Home</a>
<a href="men.html">Men</a>
<a href="women.html">Women</a>
<a href="kids.html">Kids</a>
<a href="sale.html">Sale</a>
<a href="about.html">About</a>
<a href="contact.html">Contact</a>
</nav>
<div class="nav-icons">
<a href="#" class="user-icon"><i class="fas fa-user"></i></a>
<div class="cart-count">
<a href="javascript:void(0);" onclick="showCart(); return false;" class="cart-icon"><i class="fas fa-shopping-cart"></i></a>
<span class="cart-badge" id="cartBadge">0</span>
</div>
<div class="menu-toggle" id="menuToggle">
<i class="fas fa-bars"></i>
</div>
</div>
</div>
</div>
</header>
<!-- Checkout Section -->
<section class="checkout-section">
<div class="container">
<h1 class="page-title">Checkout</h1>
<div class="checkout-grid">
<!-- Order Summary -->
<div class="order-summary">
<h2>Order Summary</h2>
<div class="cart-items" id="checkout-items">
<!-- Cart items will be loaded here via JavaScript -->
</div>
<div class="cart-summary">
<div class="summary-row">
<span>Subtotal:</span>
<span id="subtotal">₹0.00</span>
</div>
<div class="summary-row">
<span>Shipping:</span>
<span id="shipping">₹0.00</span>
</div>
<div class="summary-row">
<span>Tax:</span>
<span id="tax">₹0.00</span>
</div>
<div class="summary-row total">
<span>Total:</span>
<span id="total">₹0.00</span>
</div>
</div>
</div>
<!-- Checkout Form -->
<div class="checkout-form-container">
<form id="checkout-form" class="checkout-form">
<!-- Shipping Information -->
<div class="form-section">
<h2>Shipping Information</h2>
<div class="form-group">
<label for="full-name">Full Name <span class="required">*</span></label>
<input type="text" id="full-name" name="full-name" required>
<div class="error-message" id="full-name-error">Please enter your full name</div>
</div>
<div class="form-group">
<label for="email">Email Address <span class="required">*</span></label>
<input type="email" id="email" name="email" required>
<div class="error-message" id="email-error">Please enter a valid email address</div>
</div>
<div class="form-group">
<label for="phone">Phone Number <span class="required">*</span></label>
<input type="tel" id="phone" name="phone" required>
<div class="error-message" id="phone-error">Please enter your phone number</div>
</div>
<div class="form-group">
<label for="address">Address <span class="required">*</span></label>
<input type="text" id="address" name="address" required>
<div class="error-message" id="address-error">Please enter your address</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="city">City <span class="required">*</span></label>
<input type="text" id="city" name="city" required>
<div class="error-message" id="city-error">Please enter your city</div>
</div>
<div class="form-group">
<label for="state">State/Province <span class="required">*</span></label>
<input type="text" id="state" name="state" required>
<div class="error-message" id="state-error">Please enter your state</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="zip">Zip/Postal Code <span class="required">*</span></label>
<input type="text" id="zip" name="zip" required>
<div class="error-message" id="zip-error">Please enter your zip code</div>
</div>
<div class="form-group">
<label for="country">Country <span class="required">*</span></label>
<select id="country" name="country" required>
<option value="">Select Country</option>
<option value="USA">United States</option>
<option value="CAN">Canada</option>
<option value="UK">United Kingdom</option>
<option value="AUS">Australia</option>
<option value="GER">Germany</option>
<option value="FRA">France</option>
<option value="IND">India</option>
</select>
<div class="error-message" id="country-error">Please select your country</div>
</div>
</div>
</div>
<!-- Payment Information -->
<div class="form-section">
<h2>Payment Information</h2>
<div class="payment-methods">
<div class="payment-method">
<input type="radio" id="credit-card" name="payment-method" value="credit-card" checked required>
<label for="credit-card">Credit Card</label>
</div>
<div class="payment-method">
<input type="radio" id="paypal" name="payment-method" value="paypal" required>
<label for="paypal">PayPal</label>
</div>
</div>
<div id="credit-card-details">
<div class="form-group">
<label for="card-number">Card Number <span class="required">*</span></label>
<input type="text" id="card-number" name="card-number" placeholder="1234 5678 9012 3456" required>
<div class="error-message" id="card-number-error">Please enter a valid card number</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="expiry">Expiry Date <span class="required">*</span></label>
<input type="text" id="expiry" name="expiry" placeholder="MM/YY" required>
<div class="error-message" id="expiry-error">Please enter a valid expiry date</div>
</div>
<div class="form-group">
<label for="cvv">CVV <span class="required">*</span></label>
<input type="text" id="cvv" name="cvv" placeholder="123" required>
<div class="error-message" id="cvv-error">Please enter your CVV</div>
</div>
</div>
<div class="form-group">
<label for="card-name">Name on Card <span class="required">*</span></label>
<input type="text" id="card-name" name="card-name" required>
<div class="error-message" id="card-name-error">Please enter the name on your card</div>
</div>
</div>
<div id="paypal-details" style="display: none;">
<p>You will be redirected to PayPal to complete your payment.</p>
</div>
</div>
<!-- Review & Submit -->
<div class="form-section">
<div class="form-group checkbox">
<input type="checkbox" id="terms" name="terms" required>
<label for="terms">I agree to the <a href="#">Terms and Conditions</a> <span class="required">*</span></label>
<div class="error-message" id="terms-error">You must agree to the terms</div>
</div>
<button type="submit" class="btn btn-primary" id="place-order">Place Order</button>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer>
<div class="container">
<div class="footer-content">
<!-- Company Info -->
<div class="footer-column">
<h3>Elevate</h3>
<p>Premium athletic footwear for everyone. Quality, comfort, and style.</p>
<div class="social-icons">
<a href="#"><i class="fab fa-facebook-f"></i></a>
<a href="#"><i class="fab fa-twitter"></i></a>
<a href="#"><i class="fab fa-instagram"></i></a>
<a href="#"><i class="fab fa-pinterest"></i></a>
</div>
</div>
<!-- Shop Links -->
<div class="footer-column">
<h3>Shop</h3>
<ul>
<li><a href="men.html">Men</a></li>
<li><a href="women.html">Women</a></li>
<li><a href="kids.html">Kids</a></li>
<li><a href="sale.html">Sale</a></li>
<li><a href="index.html">New Arrivals</a></li>
</ul>
</div>
<!-- Help Links -->
<div class="footer-column">
<h3>Help</h3>
<ul>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="#">Shipping</a></li>
<li><a href="#">Returns</a></li>
<li><a href="#">Order Tracking</a></li>
</ul>
</div>
<!-- Newsletter -->
<div class="footer-column">
<h3>Newsletter</h3>
<p>Subscribe to get special offers and updates on new arrivals.</p>
<form class="newsletter-form">
<div class="form-group">
<input type="email" placeholder="Your email" required>
<button type="submit"><i class="fas fa-arrow-right"></i></button>
</div>
</form>
</div>
</div>
<div class="copyright">
<p>© <span id="current-year">2025</span> Elevate. All rights reserved.</p>
</div>
</div>
</footer>
<!-- Order Success Modal -->
<div id="success-modal" class="success-modal" style="display: none;">
<div class="success-modal-content">
<div class="success-modal-header">
<h3>Order Successful!</h3>
<button class="close-success-modal">×</button>
</div>
<div class="success-modal-body">
<div class="success-icon">
<i class="fas fa-check-circle"></i>
</div>
<h2>Thank You For Your Order!</h2>
<p>Your order has been placed successfully. We've sent a confirmation email with your order details.</p>
<p class="order-number">Order #: <span id="order-number">SZ12345678</span></p>
<button class="btn btn-primary" id="continue-shopping">Continue Shopping</button>
</div>
</div>
</div>
<!-- JavaScript -->
<script src="script.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Load cart items from localStorage
const cart = JSON.parse(localStorage.getItem('cart')) || [];
const checkoutItemsContainer = document.getElementById('checkout-items');
// Update summary values
updateOrderSummary(cart);
// Display cart items
if (cart.length > 0) {
let itemsHTML = '';
cart.forEach(item => {
itemsHTML += `
<div class="checkout-item">
<div class="checkout-item-img">
<img src="${item.image}" alt="${item.name}">
</div>
<div class="checkout-item-info">
<h3>${item.name}</h3>
<p class="item-price">₹${item.price.toFixed(2)}</p>
<p class="item-quantity">Quantity: ${item.quantity}</p>
</div>
<div class="checkout-item-total">
₹${(item.price * item.quantity).toFixed(2)}
</div>
</div>
`;
});
checkoutItemsContainer.innerHTML = itemsHTML;
} else {
checkoutItemsContainer.innerHTML = '<p class="empty-cart">Your cart is empty. Please add items before checkout.</p>';
document.getElementById('place-order').disabled = true;
}
// Payment method toggle
const creditCardOption = document.getElementById('credit-card');
const paypalOption = document.getElementById('paypal');
const creditCardDetails = document.getElementById('credit-card-details');
const paypalDetails = document.getElementById('paypal-details');
creditCardOption.addEventListener('change', function() {
if (this.checked) {
creditCardDetails.style.display = 'block';
paypalDetails.style.display = 'none';
}
});
paypalOption.addEventListener('change', function() {
if (this.checked) {
creditCardDetails.style.display = 'none';
paypalDetails.style.display = 'block';
}
});
// Form validation
const checkoutForm = document.getElementById('checkout-form');
checkoutForm.addEventListener('submit', function(e) {
e.preventDefault();
if (validateForm()) {
// Show success modal
document.getElementById('success-modal').style.display = 'flex';
// Generate random order number
const orderNumber = 'SZ' + Math.floor(Math.random() * 10000000);
document.getElementById('order-number').textContent = orderNumber;
// Clear cart
localStorage.removeItem('cart');
updateCartBadge(0);
}
});
// Close success modal
const closeSuccessModal = document.querySelector('.close-success-modal');
closeSuccessModal.addEventListener('click', function() {
document.getElementById('success-modal').style.display = 'none';
});
// Continue shopping button
document.getElementById('continue-shopping').addEventListener('click', function() {
window.location.href = 'index.html';
});
// Helper functions
function updateOrderSummary(cart) {
let subtotal = 0;
cart.forEach(item => {
subtotal += item.price * item.quantity;
});
const shipping = subtotal > 0 ? 12.99 : 0;
const tax = subtotal * 0.08; // 8% tax
const total = subtotal + shipping + tax;
document.getElementById('subtotal').textContent = '₹' + subtotal.toFixed(2);
document.getElementById('shipping').textContent = '₹' + shipping.toFixed(2);
document.getElementById('tax').textContent = '₹' + tax.toFixed(2);
document.getElementById('total').textContent = '₹' + total.toFixed(2);
}
function validateForm() {
let isValid = true;
// Reset all error messages
const errorMessages = document.querySelectorAll('.error-message');
errorMessages.forEach(msg => {
msg.style.display = 'none';
});
// Validate shipping information
const fullName = document.getElementById('full-name');
const email = document.getElementById('email');
const phone = document.getElementById('phone');
const address = document.getElementById('address');
const city = document.getElementById('city');
const state = document.getElementById('state');
const zip = document.getElementById('zip');
const country = document.getElementById('country');
if (!fullName.value.trim()) {
document.getElementById('full-name-error').style.display = 'block';
isValid = false;
}
if (!email.value.trim() || !isValidEmail(email.value)) {
document.getElementById('email-error').style.display = 'block';
isValid = false;
}
if (!phone.value.trim()) {
document.getElementById('phone-error').style.display = 'block';
isValid = false;
}
if (!address.value.trim()) {
document.getElementById('address-error').style.display = 'block';
isValid = false;
}
if (!city.value.trim()) {
document.getElementById('city-error').style.display = 'block';
isValid = false;
}
if (!state.value.trim()) {
document.getElementById('state-error').style.display = 'block';
isValid = false;
}
if (!zip.value.trim()) {
document.getElementById('zip-error').style.display = 'block';
isValid = false;
}
if (!country.value) {
document.getElementById('country-error').style.display = 'block';
isValid = false;
}
// Validate payment information if credit card is selected
if (document.getElementById('credit-card').checked) {
const cardNumber = document.getElementById('card-number');
const expiry = document.getElementById('expiry');
const cvv = document.getElementById('cvv');
const cardName = document.getElementById('card-name');
if (!cardNumber.value.trim() || !isValidCardNumber(cardNumber.value)) {
document.getElementById('card-number-error').style.display = 'block';
isValid = false;
}
if (!expiry.value.trim() || !isValidExpiry(expiry.value)) {
document.getElementById('expiry-error').style.display = 'block';
isValid = false;
}
if (!cvv.value.trim() || !isValidCVV(cvv.value)) {
document.getElementById('cvv-error').style.display = 'block';
isValid = false;
}
if (!cardName.value.trim()) {
document.getElementById('card-name-error').style.display = 'block';
isValid = false;
}
}
// Validate terms agreement
const terms = document.getElementById('terms');
if (!terms.checked) {
document.getElementById('terms-error').style.display = 'block';
isValid = false;
}
return isValid;
}
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
function isValidCardNumber(cardNumber) {
// Basic validation: Remove spaces and check if it's 16 digits
const digitsOnly = cardNumber.replace(/\s+/g, '');
return /^\d{16}$/.test(digitsOnly);
}
function isValidExpiry(expiry) {
// Format MM/YY
return /^\d{2}\/\d{2}$/.test(expiry);
}
function isValidCVV(cvv) {
// 3 or 4 digits
return /^\d{3,4}$/.test(cvv);
}
});
</script>
</body>
</html>