This repository was archived by the owner on Apr 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout.php
executable file
·215 lines (188 loc) · 9.38 KB
/
checkout.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
<?php include('boilerplate.php'); ?>
<?php
if (!$_SESSION['cart'] ) {
echo '<script>
location.href="cart.php"
</script>';
}
if (!isset($_SESSION['email']) ) {
echo '<script>
location.href="login.php"
</script>';
}
?>
<style type="text/css">
#radios label {
cursor: pointer;
position: relative;
}
#radios label+label {
margin-left: 50px;
}
input[type="radio"] {
opacity: 0;
position: absolute;
}
input[type="radio"]+span {
color: #888;
transition: all 0.4s;
-webkit-transition: all 0.4s;
}
input[type="radio"]:checked+span {
font-size: 1.5em;
color: #888;
}
.radio_del {
font-family: Roboto, -apple-system, sans-serif;
font-weight: 700;
color: #888;
margin-bottom: 25px;
}
#radios {
margin-bottom: 25px;
}
.radio_container {
text-align: center;
align-items: center;
}
</style>
<section class="checkout-section spad">
<div class="container checkout-form">
<div class="row">
<div class="col-lg-6">
<div class="radio_container">
<h4 class="radio_del">Choose Delievery Method</h4>
<div id="radios">
<label for="ship_home">
<input type="radio" name="ship" id="ship_home" value="home" required />
<span>New address<br><i class="fas fa-2x fa-truck"></i></span>
</label>
<label for="ship_store">
<input type="radio" name="ship" id="ship_store" value="store" required />
<span>Store Pickup<br><i class="fas fa-2x fa-store-alt"></i></span>
</label>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#ship_home").change(function() {
var shippingValidation = $(this).val();
if (shippingValidation != '') {
$("#loader").show();
$(".address-container").html("");
$.ajax({
type: 'post',
data: {
shipping_validation: shippingValidation
},
url: 'formHome.php',
success: function(returnData) {
$(".saved_address").hide();
$(".address-container").html(returnData);
}
});
}
})
});
$(document).ready(function() {
$("#ship_store").change(function() {
var shippingValidation = $(this).val();
console.log(shippingValidation);
if (shippingValidation != '') {
$("#loader").show();
$(".address-container").html("");
$.ajax({
type: 'post',
data: {
shipping_validation: shippingValidation
},
url: 'formStore.php',
success: function(returnData) {
$(".saved_address").hide();
$(".address-container").html(returnData);
}
});
}
})
});
</script>
<div class="address-container">
</div>
<div class="saved_address row">
<?php
$query = "SELECT * FROM shipping WHERE shipping_type= 'home'
and customer_id = '$customer_id' ORDER BY shipping_id DESC";
$result = mysqli_query($connect, $query);
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['shipping_id']; ?>
<div class="container" style="margin-bottom: 30px;">
<p>
<a style="color: #888; margin-left: 10px;" href="delAddress.php?id=<?php echo $row['shipping_id'] ?>" class='pull-right' id='del_<?= $id ?>'>
<i class="far fa-trash-alt"></i></a>
<a style="color: #888; margin-left: 10px;" href="updateAddress.php?id=<?php echo $row['shipping_id'] ?>" class="pull-right">
<i class="fas fa-wrench"></i></a>
</p>
<input type="hidden" value="<?php echo $row['shipping_id'] ?>">
<p><?php echo $row['full_name'] ?></p>
<p><?php echo $row['phone'] ?></p>
<p><?php echo $row['street_address'] ?>,<?php echo $row['city'] ?>,<?php echo $row['state'] ?>
<a href="payment.php?id=<?php echo $row['shipping_id'] ?>" class="btn btn-sm btn-success pull-right">Proceed<i style=" margin-left: 10px;" class="fas fa-arrow-right"></i></a>
</p>
</div>
<?php } ?>
</div>
</div>
<div class="col-lg-5 ml-auto">
<div class="place-order">
<div class="order-total">
<ul class="order-table">
<li>Product <span>Total</span></li>
<?php
if (isset($_SESSION['cart'])) {
$total = 0;
$itemqty = 0;
foreach ($_SESSION['cart'] as $variant_id => $quantity) {
$find_pro_id = mysqli_query($connect, "SELECT * FROM variant WHERE variant_id='$variant_id'");
$pro_data = mysqli_fetch_assoc($find_pro_id);
$product_id = $pro_data['product_id'];
$result = "SELECT name, cost, qty, file FROM product WHERE id = '$product_id'";
$result_2 = mysqli_query($connect, "SELECT color,size FROM variant where variant_id='$variant_id'");
$attr_prop = mysqli_fetch_assoc($result_2);
$color_id = $attr_prop['color'];
$size_id = $attr_prop['size'];
$result_3 = mysqli_query($connect, "SELECT value FROM attribute where attr_id='$color_id'");
$variant_prop = mysqli_fetch_assoc($result_3);
$color = $variant_prop['value'];
$result_4 = mysqli_query($connect, "SELECT value FROM attribute where attr_id='$size_id'");
$variant_prop = mysqli_fetch_assoc($result_4);
$size = $variant_prop['value'];
$run = mysqli_query($connect, $result);
if ($run) {
while ($obj = mysqli_fetch_object($run)) {
$price = $obj->cost * $quantity;
$total = $total + $price;
$itemqty = $itemqty + $quantity;
echo '<li class="fw-normal">
<img src="uploads/' . $obj->file . '" width="25" height="30" alt="cover image">
<b>' . $obj->name . '</b> ';
if ($color == 'white') {
echo'<a class="badge" style="color:black; background-color:' .$color .';">' . $size .'</a>';
} else {
echo'<a class="badge" style="color:white; background-color:' .$color .';">' . $size .'</a>';
}
echo' (' . $quantity . ')<span>₹ ' . $obj->cost . '</span></li>';
}
}
}
echo '<li class="fw-normal">Total Quantity<span>' . $itemqty . ' pcs</span></li>
<li class="total-price">Total <span class="text-success"> ₹ ' . $total . '</span></li>
</ul>';
}
?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include('footer.php'); ?>