-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout.php
More file actions
196 lines (172 loc) · 9.4 KB
/
checkout.php
File metadata and controls
196 lines (172 loc) · 9.4 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
<?php
include("config/session.php");
$conn = $pdo->open();
if(!isset($_SESSION['user'])) {
$_SESSION['error'] = "Sorry, you have to login to checkout";
header('location: index.php');
} else {
$user = $_SESSION['user']['user_id'];
$stmt = $conn->prepare("SELECT * FROM cart LEFT JOIN products on cart.prd_id = products.prd_id WHERE user_id = :user_id");
$stmt->execute([':user_id' => $user]);
$cart_items = $stmt->fetchAll();
}
include('config/fetch.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicons -->
<link rel="icon" href="images/favicon-32x32.png" sizes="32x32">
<link rel="icon" href="images/favicon-192x192.png" sizes="192x192">
<link rel="apple-touch-icon" href="images/favicon-180x180.png">
<!-- HEADER & FOOTER CSS -->
<link rel="stylesheet" href="styles/header-and-footer.css?v=<?php echo time(); ?>"/>
<!-- PAGE CSS -->
<link rel="stylesheet" href="styles/checkout.css?v=<?php echo time(); ?>"/>
<!-- FONT AWESOME ICONS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Checkout- Doppell</title>
</head>
<body>
<?php include('includes/header.php'); ?>
<main>
<section class="checkout-breadcrumbs">
<div class="container">
<nav class="breadcrumbs">
<a href="cart.php">Shopping Cart</a>
<span class="divider hide-for-small"><i class="fas fa-angle-right"></i></span>
<a href="checkout.php" class="current">Checkout details</a>
<span class="divider hide-for-small"><i class="fas fa-angle-right"></i></span>
<a href="">Order Complete</a>
</nav>
</div>
</section>
<section class="checkout-main">
<div class="container">
<div class="coupon">
<div class="coupon-text">
<p>Have a coupon? <span class="show-coupon">Click here to enter your code</span></p>
</div>
<form action="" class="checkout-coupon hidden form">
<p>If you have a coupon code, please apply it below.</p>
<div class="checkout-coupon-form">
<div>
<input type="text" name="coupon_code" class="input-text" placeholder="Coupon code" id="coupon_code">
</div>
<div>
<button type="submit" class="" name="apply_coupon" value="Apply coupon">Apply coupon</button>
</div>
</div>
</form>
</div>
<div class="checkout-form">
<form action="" class="form">
<h3>Billing details</h3>
<div class="first-name">
<label for="first_name">First name <span class="required">*</span></label>
<input type="text" name="first_name" id="first_name">
</div>
<div class="last-name">
<label for="last_name">Last name <span class="required">*</span></label>
<input type="text" name="last_name" id="last_name">
</div>
<div>
<label for="company_name">Company name (optional)</label>
<input type="text" name="company_name" id="company_name">
</div>
<div>
<label for="country">Country / Region <span class="required">*</span></label>
<input type="text" name="country" id="country" placeholder="Nigeria">
</div>
<div class="address">
<label for="address">Street address <span class="required">*</span></label>
<input type="text" name="street_name" id="street_name" placeholder="House number and street name">
</div>
<div class="apartment">
<label for=""></label>
<input type="text" name="apartment_name" id="apartment_name" placeholder="Apartment, suite, unit, etc. (optional)">
</div>
<div>
<label for="city">Town / City <span class="required">*</span></label>
<input type="text" name="city" id="city">
</div>
<div>
<label for="state">State / County <span class="required">*</span></label>
<input type="text" name="state" id="state">
</div>
<div>
<label for="postcode">Postcode / ZIP <span class="required">*</span></label>
<input type="number" name="postcode" id="postocode">
</div>
<div>
<label for="phone">Phone <span class="required">*</span></label>
<input type="tel" name="phone" id="phone">
</div>
<div>
<label for="email">Email address <span class="required">*</span></label>
<input type="email" name="email" id="email">
</div>
<h3>Additional information</h3>
<div class="additional-info">
<label for="additional_info">Order notes (optional)</label>
<textarea name="additional_info" id="additional_info" placeholder="Notes about your order, e.g. special notes for delivery."></textarea>
</div>
</form>
</div>
<div class="checkout-details">
<div class="inner-col">
<h3>Your order</h3>
<table>
<thead>
<tr>
<th class="product-name">Product</th>
<th class="product-total">Subtotal</th>
</tr>
</thead>
<tbody>
<?php foreach($cart_items as $cart_item): ?>
<tr class="cart-item">
<td class="product-name">
<?php echo $cart_item['prd_name']; ?><span class="product-quantity">× <?php echo $cart_item['quantity']; ?></span>
</td>
<td class="product-total">
<span class="product-total-price"><?php $subtotal = $cart_item['prd_price'] * $cart_item['quantity'] ; echo '₦' . number_format($subtotal, 2); ?></span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th>Subtotal</th>
<td><span class="subtotals"></span></td>
</tr>
<tr class="order-total">
<th>Total</th>
<td><span class="subtotals"></span></td>
</tr>
</tfoot>
</table>
<p>Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.</p>
<form action="">
<label><input type="checkbox"> I would like to receive exclusive emails with discounts and product information (optional)</label>
</form>
<button type="submit">Place order</button>
<p class="privacy-policy">Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our <a href="" target="_blank">privacy policy</a>.</p>
</div>
</div>
</div>
</section>
</main>
<?php include('includes/footer.php'); ?>
<script>
const openCoupon = $('.checkout-main .coupon-text span.show-coupon');
const couponContainer = $('.checkout-main .checkout-coupon');
openCoupon.click(function() {
couponContainer.toggleClass('hidden');
})
</script>
</body>
</html>