-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathordersummary.html
149 lines (136 loc) · 5.67 KB
/
ordersummary.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Summary</title>
<!-- Bootstrap CSS (optional, for styling) -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Custom CSS for order summary -->
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
padding-top: 20px;
}
.container {
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
margin-top: 20px;
}
.order-details {
margin-bottom: 20px;
}
.order-items {
list-style-type: none;
padding: 0;
}
.order-items li {
margin-bottom: 10px;
border-bottom: 1px solid #ccc;
padding-bottom: 5px;
}
.order-items li:last-child {
border-bottom: none;
}
.total {
margin-top: 10px;
font-weight: bold;
}
.quantity-input {
width: 60px;
text-align: center;
}
.form-group {
margin-bottom: 15px;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center">Order Summary</h1>
<div class="order-details">
<ul class="order-items">
<!-- Order items will be dynamically added here -->
</ul>
<div class="total text-right">
<h3>Total Amount: <span id="total-amount">Rp. 0</span></h3>
</div>
<!-- Form for additional information -->
<form id="order-form">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="address">Address:</label>
<textarea id="address" name="address" class="form-control" rows="3" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Place Order</button>
</form>
</div>
</div>
<!-- Optional: jQuery (for Bootstrap) and Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- Custom JavaScript for order summary -->
<script>
document.addEventListener('DOMContentLoaded', function() {
const orderItemsList = document.querySelector('.order-items');
const totalAmountDisplay = document.getElementById('total-amount');
const orderForm = document.getElementById('order-form');
// Example data (you should replace this with your actual data handling)
const orderData = JSON.parse(localStorage.getItem('orderData')) || [];
if (orderData && orderData.length > 0) {
let totalAmount = 0;
orderData.forEach((item, index) => {
const itemTotal = item.price * item.quantity;
totalAmount += itemTotal;
const orderItemHTML = `
<li>
<span>${index + 1}. ${item.product} (<span class="quantity">${item.quantity}</span> pcs)</span>
<span>Rp. ${itemTotal.toLocaleString()}</span>
</li>
`;
orderItemsList.innerHTML += orderItemHTML;
});
// Display total amount
totalAmountDisplay.textContent = `Rp. ${totalAmount.toLocaleString()}`;
// Update quantity input fields
const quantityInputs = document.querySelectorAll('.quantity');
quantityInputs.forEach((quantity, index) => {
const item = orderData[index];
quantity.textContent = item.quantity;
});
} else {
// Handle case when there are no orders
orderItemsList.innerHTML = '<li>No items in order</li>';
totalAmountDisplay.textContent = `Rp. 0`;
}
// Handle form submission (you can add more validation and processing here)
orderForm.addEventListener('submit', function(event) {
event.preventDefault();
// Example: Save form data (replace with your actual processing logic)
const formData = new FormData(orderForm);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
// Example: Send data to server or process further
console.log('Form Data:', data);
// Example: Clear localStorage after placing order (adjust as needed)
localStorage.removeItem('orderData');
// Example: Redirect to thank you page or homepage after order is placed
window.location.href = 'thankyou.html';
});
});
</script>
</body>
</html>