-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcart.html
177 lines (155 loc) · 7.03 KB
/
cart.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
<!DOCTYPE html>
<html>
<head>
<title>Shopping Cart</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" rel="stylesheet" />
<link href="./css/cart-style.css" rel="stylesheet">
</head>
<body>
<section>
<div class="container">
<div class="cart">
<div class="col-md-12 col-lg-10 mx-auto">
<div class="cart-item">
<div class="row">
<div class="col-md-7 center-item">
<img src="./images/ff-1.jpg" alt="">
<h5>Very Nice</h5>
</div>
<div class="col-md-5 center-item">
<div class="input-group number-spinner">
<button onclick="handleProductChange('phone',false)" id="phone-decrease" class="btn btn-default"><i class="fas fa-minus"></i></button>
<input id="phone-count" type="text" class="form-control text-center" value="1">
<button id="phone-increase" class="btn btn-default"><i class="fas fa-plus"></i></button>
</div>
<h5 id="phone-total">$50</h5>
<img src="images/remove.png" alt="" class="remove-item">
</div>
</div>
</div>
<div class="cart-item">
<div class="row">
<div class="col-md-7 center-item mx-auto">
<img src="./images/ff-5.jpg" alt="">
<h5>The Hobbit</h5>
</div>
<div class="col-md-5 center-item">
<div class="input-group number-spinner">
<button id="case-decrease" class="btn btn-default"><i class="fas fa-minus"></i></button>
<input id="case-count" type="text" class="form-control text-center" value="1">
<button onclick="handleProductChange('case',true)" id="case-increase" class="btn btn-default"><i class="fas fa-plus"></i></button>
</div>
<h5 id="case-total">$70</h5>
<img src="images/remove.png" alt="" class="remove-item">
</div>
</div>
</div>
<div class="cart-item">
<div class="row">
<div class="col-md-8">
<h5>Subtotal: </h5>
<h5>Tax:</h5>
<h5>Total:</h5>
</div>
<div class="col-md-4 status">
<h5 id="total-price">$120</h5>
<h5 id="tax-amount">$0</h5>
<h5 id="grand-total">$120</h5>
</div>
</div>
</div>
<div class="col-md-12 pt-4 pb-4">
<button onclick="showAlert()" id="check-out" type="button" class="btn btn-success check-out">Check Out</button>
</div>
</div>
</div>
</div>
</section>
<script src="./js/cart-script.js"></script>
<script>
// document.getElementById('case-decrease').addEventListener('click', function(){
// handleProductChange('case',false);
// })
// document.getElementById('phone-increase').addEventListener('click', function(){
// handleProductChange('phone',true);
// })
// function handleProductChange(product, isIncrease){
// const productInput=document.getElementById(product+'-count');
// const productCount=parseInt(productInput.value);
// let productNewCount=productCount;
// if(isIncrease==true){
// productNewCount=productCount+1;
// }
// if(isIncrease==false && productCount>0){
// productNewCount=productCount-1;
// }
// productInput.value=productNewCount;
// // const caseTotal=caseNewCount*59;
// let productTotal=productNewCount;
// if(product=='phone'){
// productTotal=productNewCount*1219;
// }
// if(product=='case'){
// productTotal=productNewCount*59;
// }
// document.getElementById(product+'-total').innerText='$' + productTotal;
// calculateTotal();
// }
// function calculateTotal(){
// const phoneInput=document.getElementById('phone-count');
// const phoneCount=parseInt(phoneInput.value);
// const caseCount=getInputValue('case');
// const totalPrice=phoneCount*1219 + caseCount*59;
// document.getElementById('total-price').innerText='$' + totalPrice;
// const tax=(totalPrice * 0.1).toFixed(3);
// document.getElementById('tax-amount').innerText='$' + tax;
// const grandTotal=tax + totalPrice;
// document.getElementById('grand-total').innerText='$' + grandTotal;
// }
// function getInputValue(product){
// const productInput=document.getElementById(product+'-count');
// const productCount=parseInt(productInput.value);
// return productCount;
// }
// document.getElementById('case-decrease').addEventListener('click', function(){
// // const caseInput=document.getElementById('case-count');
// // const caseCount=parseInt(caseInput.value);
// // const caseNewCount=caseCount-1;
// // caseInput.value=caseNewCount;
// // const caseTotal=caseNewCount*59;
// // document.getElementById('case-total').innerText='$' + caseTotal;
// })
// function handleProductChange(isIncrease){
// const caseInput=document.getElementById('case-count');
// const caseCount=parseInt(caseInput.value);
// let caseNewCount=caseCount;
// if(isIncrease==true){
// caseNewCount=caseCount+1;
// }
// if(isIncrease==false && caseCount>0){
// caseNewCount=caseCount-1;
// }
// caseInput.value=caseNewCount;
// const caseTotal=caseNewCount*59;
// document.getElementById('case-total').innerText='$' + caseTotal;
// }
// function handlePhoneChange(isIncrease){
// const phoneInput=document.getElementById('phone-count');
// const phoneCount=parseInt(phoneInput.value);
// let phoneNewCount=phoneCount;
// if(isIncrease==true){
// phoneNewCount=phoneCount+1;
// }
// if(isIncrease==false && phoneCount>0){
// phoneNewCount=phoneCount-1;
// }
// phoneInput.value=phoneNewCount;
// const phoneTotal=phoneNewCount*1219;
// document.getElementById('phone-total').innerText='$' + phoneTotal;
// }
</script>
</body>
</html>