-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart2.html
478 lines (382 loc) · 15.8 KB
/
cart2.html
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
<!doctype html>
<html>
<head>
<meta charset= “utf-8”>
<meta content="width=device-width, initial-scale=1" name="viewport" />
<title>Your Cart</title>
<link rel="stylesheet" href="CSS/rules_cart.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="CSS/universal_rules.css">
<!-- <link rel="stylesheet" href="header.css"> -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
<style>
textarea {resize:none;} /* KEEP IT IN THE IN-STYLE SHEET*/
#banner-box {
width: 100vw;
background-color: #F1EBD3;
background-image: url('images/food_market.jpg');
}
#banner-box h1 {
text-align: center;
color: white;
font-size: 5rem;
padding: 40px;
}
h2 {
color:#BF2608;
}
</style>
</head>
<body>
<div class="hold-header">
<div id="header" class="header-wrapper">
<header class="header">
<a href="index.html"><img src="./images/logo.png" class="header-logo"></a>
<nav class="header-nav">
<ul>
<li><a href="./index.html">Home</a></li>
<li><a href="./recipes.html">Recipes</a></li>
<li><a href="./aboutus.html">About</a></li>
<li><a href="./your_cart.html">Cart</a></li>
</ul>
</nav>
</header>
</div>
</div>
<div>
<section id='banner-box'> <!-- Main Title Section -->
<h1>Your Cart</h1>
</section>
<section id='content-box'> <!-- this is the father that will hold the two columns-->
<form action= "process.php" method = "post" onsubmit=" return submitClicked()">
<div class = 'content-column'> <!-- column child of the father content box -->
<div class='content-personal-box'> <!-- PERSONAL INFORMATION BOX-->
<h2>Delivery Information</h2> <br>
<div>
<label for="name">First Name</label>
<input id="name" type="text" />
</div>
<div>
<label for="lname">Last Name</label>
<input id="lname" type="text" />
</div>
<div>
<label for="street">Street</label>
<input id="street" type="text" />
</div>
<div>
<label for="stateselector">State</label>
<input list="states" id="stateselector" type="text">
<datalist id="states">
<script>
// list of all states that user can select
stateList = new Array ("Alabama", "Alaska", "Arizona", "Arkansas", "California",
"Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii",
"Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana",
"Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi",
"Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey",
"New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma",
"Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota",
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia",
"Wisconsin", "Wyoming")
for (i in stateList) {
toAdd = "<option value= \"" + stateList[i] + "\">"
document.writeln(toAdd)
}
</script>
</datalist>
</div>
<div>
<label for="zip">Zip Code</label>
<input type="text" id="zip">
</div>
<div></div>
<div style="grid-column: 1 / -1;">
<label for="notes">Delivery Notes</label>
<textarea id="notes" rows="3" cols="20"></textarea>
</div>
</div>
<br>
<div class="content-personal-box" id="content-credit"> <!-- FORM BOX -->
<h2>Payment Information</h2>
<div style="grid-column: 1 / -1;">
<label for="cardnumber">Credit Card</label>
<input id="cardnumber" type="text" placeholder="•••• •••• •••• ••••" />
</div>
<div></div>
<div style="grid-column: 1 / -1;">
<label for="cvv">CVV</label>
<input id="cvv" type="text" placeholder="•••" />
</div>
</div><!-- end col of form box credit card -->
</div> <!-- end of col1 - first child -->
<div class="content-column"> <!-- Second child - colun -->
<div id='cart-box'> <!-- products column -->
<h2> Our Menu </h2>
<table border="0" cellpadding="10" class="items" style="grid-column: 1 / -1;">
<script>
// constructor for recipe
function recipe(name, cost){
this.name = name;
this.cost=cost;
}
// all possible recipes in the cart
recipes = new Array (
new recipe("ceviche", 25.00),
new recipe("pao de queijo", 18.00),
new recipe("alfajor", 15.00)
)
var s = "";
// list all recipes, images, prices, and allow user to select how many they want
for (i=0; i< recipes.length; i++) {
s += "<tr>";
recipepic = recipes[i].name + ".jpeg";
if (recipes[i].name == "pao de queijo"){
recipepic = "paodequeijo.jpg";
}
s += "<td class='ico'><img src = \"images/" + recipepic + "\"></td>";
s += "<td class='type'><p>" + recipes[i].name + "</p></td>";
s += "<td class='price'><p>$" + recipes[i].cost + " each</p></td>";
s += "<td class='selector'>" + makeSelector(i) + "</td>"
s+= "</tr>";
}
document.writeln(s);
// makes a plus and minus button and displays the quantity for each recipe
function makeSelector(index2) {
index = index2;
plusButton = "<img src= \"images/plus.png \" width= \"20 \" height= \" 20 \" onclick = \"change(0," + index + ") \">"
minusButton = "<img src= \"images/negative-sign.png \" width= \"20 \" height= \" 20 \" onclick = \"change(1," + index + ")\">"
amountDisplay = "<p class = \" amount \">0</p>"
return (plusButton + amountDisplay + minusButton);
}
// runs when user clicks + or - to change the quantity ordered
function change(operation, index) {
if (operation == 0)
$('.amount')[index].textContent = parseInt($('.amount')[index].textContent) + 1;
else{
if (parseInt($('.amount')[index].textContent) > 0)
$('.amount')[index].textContent = parseInt($('.amount')[index].textContent) - 1;
}
updatecosts()
}
// updates subtotal, shipping fee, and order total whenever quantity is changed
function updatecosts() {
subtotal = 0;
for (i = 0; i < recipes.length; i++){
individualPrice = recipes[i].cost;
quantity = parseInt($('.amount')[i].textContent);
subtotal += (quantity * individualPrice);
}
$('#subtotal')[0].textContent = "Subtotal: $" + twoDecimal(subtotal);
$('#shippingFee')[0].textContent = "Shipping Fee: $" + twoDecimal(subtotal * .05);
$('#orderTotal')[0].textContent = "Total: $" + twoDecimal((subtotal * .05) + subtotal);
}
// makes it so that all costs will have two decimal places. Taken from Andrew's Jade Delight
function twoDecimal(number) {
if ((number * 1000) % 10 >= 5){
number = (Math.ceil(100*number) / 100);
}
else {
number = (Math.floor(100*number) / 100);
}
if ((number * 10) % 10 == 0)
number = number + ".00";
else if ((number * 100) % 10 == 0)
number = number + "0";
return number;
}
</script>
</table>
<div class="Finals">
<div></div> <!-- invisible column for grid -->
<div id="calculations">
<p id=subtotal>Subtotal: $0.00</p>
<p id =shippingFee>Shipping Fee: $0.00</p>
<br></r><hr><br>
<p id= orderTotal>Total: $0.00</p>
</div>
</div>
</div><!-- end col 2 - second child -->
<br><br>
<button id="button_cart"><p>CHECKOUT</p></button>
<input type="submit" id="submit_button" value= "CHECKOUT"></input>
</form>
<script>
// when the user submits, first validate the form, then if valid, open the confirmation window
function submitClicked(){
if (validate()){
myWindow = window.open("", "OrderSummary", "width=1000,height=500");
myWindow.document.write('<html><head><link rel="stylesheet" type="text/css" href="CSS/simple.css"></head><body>');
myWindow.document.writeln("<h1>Gracias! Thank you for your order, " + $('#name')[0].value + "!</h1>");
myWindow.document.writeln("<p>You Ordered: </p><ul>")
for (i = 0; i < recipes.length; i++){
if($('.amount')[i].textContent != 0)
myWindow.document.writeln("<li><strong>" + $('.amount')[i].textContent + "x " + recipes[i].name + "</strong></li>")
}
myWindow.document.writeln("<p>Your Order Total Was: " + $('#orderTotal')[0].textContent.substr(6) + "</p>");
myWindow.document.writeln("</ul><p>Confirmation Number: #" + Math.round(Math.random() * 1000000000) + "</p>");
myWindow.document.writeln("<p>Your order will be shipped shortly and should arrive in 5-7 business days!</p></body></html>");
myWindow.document.writeln("<img src='images/checkmark3.png'>")
return true;
}
return false;
}
// validates each field of the form, alerting the user if there are errors
function validate() {
valid = false;
statevalid = false;
orderedSomething = false;
// check that the user ordered something
for (i = 0; i < recipes.length; i++) {
if ($('.amount')[i].textContent != 0){
orderedSomething = true;
}
}
if (!orderedSomething){
alert('You did not order anything!');
}
// check that the user selected a valid state
for (i in stateList) {
if ($('#stateselector')[0].value == stateList[i]){
statevalid = true;
valid = true;
}
}
// check that the user entered their first name
if ($('#name')[0].value == ""){
valid = false;
alert('Please enter your first name!');
}
// check that the user entered their last name
if ($('#lname')[0].value == ""){
valid = false;
alert('Please enter your last name!');
}
// check that the user entered a street address
if ($('#street')[0].value == ""){
valid = false;
alert('Please enter your street address!');
}
if (!(statevalid)){
alert('Please enter a valid state!')
}
zipvalid = true;
// check that the user entered a 5-digit zip
for (i in $('#zip')[0].value)
if (isNaN($('#zip')[0].value[i])){
zipvalid = false;
}
if (zipvalid == false || $('#zip')[0].value.length != 5){
valid = false;
alert('Please enter a valid 5-digit ZIP code!')
}
// check that the user entered a 15 or 16-digit credit card number
digitcounter = 0
for (i in $('#cardnumber')[0].value){
if (!(isNaN($('#cardnumber')[0].value[i])))
digitcounter++;
else
digitcounter = 1000;
}
if (digitcounter != 15 && digitcounter != 16){
alert('Please enter a valid 15 or 16-digit credit card number (only digits)!');
valid = false;
}
digitcounter = 0
// check that the user entered a 3 digit CVV
for (i in $('#cvv')[0].value){
if (!(isNaN($('#cvv')[0].value[i])))
digitcounter++;
else
digitcounter = 1000;
}
if (digitcounter != 3){
alert('Please enter a valid three-digit CVV!');
valid = false;
}
return (valid && orderedSomething);
}
</script>
</div>
</section> <!-- end content-->
<section class="slide-box">
<h2>Read more about all of our recipes!</h2> <br>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> -->
<div class="container">
<ul class="horscroll" id="autoscrollR">
<li>
<div class="card">
<a href="recipe1.html">
<img src="images/ceviche.jpeg" alt="Ceviche">
<div class="title-line">
<object data="images/peru.png"> </object>
<p class="price"> Ceviche </p>
</div>
<p class="description">Ceviche is a seafood dish where diced cubes of raw fish, marinated in a lemon or lime juice mixture,
react with the citrus juices to cure the fish protein and causes it to become opaque and firm while absorbing flavor.</p>
</a>
</div>
</li>
<li>
<div class="card">
<a href="recipe2.html">
<img src="images/paodequeijo.jpg" alt="Ceviche">
<div class="title-line">
<object data="images/bandeirabrasil.jpeg"> </object>
<p class="price"> Pão de queijo </p>
</div>
<p class="description">Pão de queijo or Cheese Bread is a typical Brazilian snack. It originated in the 18th century and
its ingredients include manioc starch and “meia cura” cheese.</p>
</a>
</div>
</li>
<li>
<div class="card">
<a href="recipe3.html">
<img src="images/alfajor.jpeg" alt="Ceviche">
<div class="title-line">
<object data="images/bandeiraargentina.png"> </object>
<p class="price"> Alfajor </p>
</div>
<p class="description">Alfajor is buttery cornstarch cookie sandwich filled with dulce de leche. It was brought to
South America in the 16th century with the invasion of the Spanish conquistadors. It is very popular in Argentina.</p>
</a>
</div>
</li>
<li>
<div class="card">
<a href="recipe4.html">
<img src="images/enchilada.jpg" alt="Ceviche">
<div class="title-line">
<object data="images/flagmexico.png"> </object>
<p class="price"> Enchilada </p>
</div>
<p class="description">Enchilada is a Mexican dish that dates back at least to Aztec times. It consists of a corn tortilla
rolled around a filling and covered with a savory sauce. It can be filled with meats, cheese, beans and vegetables.</p>
</a>
</div>
</li>
</ul>
</div>
<br><br>
</section>
<div id="footer" class="footer-wrapper">
<footer class="footer">
<ul class="footer-otherLinks">
<li class="footer-listItem"><a href="recipes.html">Recipes</a></li>
<li class="footer-listItem"><a href="aboutus.html">About Us</a></li>
<li class="footer-listItem"><a href="your_cart.html">Cart</a></li>
</ul>
<ul class="footer-socialMedia">
<li><a href="https://www.facebook.com"><i class="fa fa-facebook"></i></a></li>
<li><a href="https://twitter.com"><i class="fa fa-twitter"></i></a></li>
<li><a href="https://www.instagram.com"><i class="fa fa-instagram"></i></a></li>
<li><a href="https://www.youtube.com"><i class="fa fa-youtube"></i></a></li>
<li><a href="https://www.pinterest.com"><i class="fa fa-pinterest"></i></a></li>
</ul>
<p class="footer-copyRights">© 2022 Flavors De La Casa -US, Inc. All Rights Reserved.</p>
</footer>
</div>
</body>
</html>