Spaces:
Sleeping
Sleeping
Update templates/order_history.html
Browse files- templates/order_history.html +26 -1
templates/order_history.html
CHANGED
@@ -107,7 +107,8 @@
|
|
107 |
|
108 |
<!-- Reorder and Rate buttons -->
|
109 |
<div class="order-buttons">
|
110 |
-
<button class="reorder-btn">Reorder</button>
|
|
|
111 |
<button class="rate-order-btn">Rate Order</button>
|
112 |
</div>
|
113 |
</div>
|
@@ -120,6 +121,30 @@
|
|
120 |
</div>
|
121 |
{% endif %}
|
122 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
</body>
|
125 |
</html>
|
|
|
107 |
|
108 |
<!-- Reorder and Rate buttons -->
|
109 |
<div class="order-buttons">
|
110 |
+
<button class="reorder-btn" onclick="reorder('{{ order.Id }}')">Reorder</button>
|
111 |
+
|
112 |
<button class="rate-order-btn">Rate Order</button>
|
113 |
</div>
|
114 |
</div>
|
|
|
121 |
</div>
|
122 |
{% endif %}
|
123 |
</div>
|
124 |
+
<script>
|
125 |
+
function reorder(orderId) {
|
126 |
+
fetch(`/reorder/${orderId}`, {
|
127 |
+
method: 'POST',
|
128 |
+
headers: {
|
129 |
+
'Content-Type': 'application/json',
|
130 |
+
},
|
131 |
+
body: JSON.stringify({ orderId: orderId }),
|
132 |
+
})
|
133 |
+
.then(response => response.json())
|
134 |
+
.then(data => {
|
135 |
+
if (data.success) {
|
136 |
+
// Redirect to the cart page after adding the items
|
137 |
+
window.location.href = '/cart'; // Or any cart page URL
|
138 |
+
} else {
|
139 |
+
alert("Error reordering: " + data.error);
|
140 |
+
}
|
141 |
+
})
|
142 |
+
.catch(error => {
|
143 |
+
console.error('Error:', error);
|
144 |
+
});
|
145 |
+
}
|
146 |
+
|
147 |
+
</script>
|
148 |
|
149 |
</body>
|
150 |
</html>
|