-
Notifications
You must be signed in to change notification settings - Fork 27
/
checkout.html
95 lines (84 loc) · 3.29 KB
/
checkout.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
{% extends 'shop/basic.html' %}
{% block title%} Checkout - My Awesome Cart{% endblock %}
{% block body %}
<div class="container">
<div class="col my-4">
<h2>Step 1 - My Awesome Cart Express Checkout - Review Your Cart Items</h2>
<div >
<ul class="list-group" id="items">
</ul>
</div>
</div>
<div class="col my-4">
<h2>Step 2 - Enter Address & Other Details:</h2>
<form action="/shop/checkout/" method="POST">
{% csrf_token %}
<input type="hidden" name="itemsjson" id="itemsjson">
<div class="form-row">
<div class="form-group col-md-6">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" name="name"placeholder="Name">
</div>
<div class="form-group col-md-6">
<label for="Email">Email</label>
<input type="email" class="form-control" id="Email" name="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="Address1">Address</label>
<input type="text" class="form-control" id="Address" name="address1" placeholder="1234 Main St">
</div>
<div class="form-group">
<label for="Address2">Address line 2</label>
<input type="text" class="form-control" id="Address" name="address2" placeholder="Apartment, studio, or floor">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="City">City</label>
<input type="text" class="form-control" id="City" name="city">
</div>
<div class="form-group col-md-4">
<label for="State">State</label>
<input type="text" class="form-control" id="State" name="state" placeholder="Enter State">
</div>
<div class="form-group col-md-2">
<label for="Zip">Zip</label>
<input type="text" class="form-control" id="Zip" name="zip_code">
</div>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
<button type="submit" class="btn btn-info">Place Order</button>
</form>
</div>
</div>
{% endblock %}
{% block js %}
<script>
if (localStorage.getItem('cart') == null) {
var cart = {};
}
else
{
cart = JSON.parse(localStorage.getItem('cart'));
document.getElementById('cart').innerHTML = Object.keys(cart).length;
}
for(item in cart){
let name=cart[item][1];
let quant=cart[item][0];
mystr=` <li class="list-group-item d-flex justify-content-between align-items-center">
${name}
<span class="badge badge-danger badge-pill">${quant}</span>
</li>`
$('#items').append(mystr);
}
document.getElementById("cart").innerHTML=Object.keys(cart).length;
$('#itemsjson').val(JSON.stringify(cart))
{% if thank %}
localStorage.clear();
document.location='/shop';
{% endif %}
</script>
{% endblock %}