Spaces:
Sleeping
Sleeping
Update templates/order_history.html
Browse files- templates/order_history.html +9 -10
templates/order_history.html
CHANGED
@@ -126,24 +126,24 @@
|
|
126 |
<script>
|
127 |
function addToCart(itemName) {
|
128 |
const button = document.getElementById(itemName); // Get the button element by its ID
|
129 |
-
let itemPrice = button.dataset.price;
|
130 |
-
const itemImage = button.dataset.image;
|
131 |
-
const category = button.dataset.category;
|
132 |
-
const section = button.dataset.section;
|
133 |
|
134 |
-
// Ensure the price is
|
135 |
-
itemPrice = String(itemPrice); //
|
136 |
|
|
|
137 |
if (!itemPrice || !itemImage || !itemName || !category || !section) {
|
138 |
alert('Missing required item data.');
|
139 |
return;
|
140 |
}
|
141 |
|
142 |
-
//
|
143 |
-
const numericItemPrice = parseFloat(itemPrice.replace('$', '').trim()); // Convert to numeric value
|
144 |
const dataToSend = {
|
145 |
itemName: itemName,
|
146 |
-
itemPrice:
|
147 |
itemImage: itemImage,
|
148 |
addons: [], // Example: No addons for now
|
149 |
instructions: "", // Example: No instructions for now
|
@@ -171,7 +171,6 @@
|
|
171 |
});
|
172 |
}
|
173 |
|
174 |
-
|
175 |
</script>
|
176 |
|
177 |
</body>
|
|
|
126 |
<script>
|
127 |
function addToCart(itemName) {
|
128 |
const button = document.getElementById(itemName); // Get the button element by its ID
|
129 |
+
let itemPrice = button.dataset.price; // Get price from data-price attribute
|
130 |
+
const itemImage = button.dataset.image; // Get image URL from data-image attribute
|
131 |
+
const category = button.dataset.category; // Category of the item
|
132 |
+
const section = button.dataset.section; // Section of the item
|
133 |
|
134 |
+
// Ensure the price is treated as a string (e.g., "$16.0")
|
135 |
+
itemPrice = String(itemPrice); // Convert item price to a string (e.g., "$16.0")
|
136 |
|
137 |
+
// Validate that all required data is available
|
138 |
if (!itemPrice || !itemImage || !itemName || !category || !section) {
|
139 |
alert('Missing required item data.');
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
+
// Send data to the backend as JSON
|
|
|
144 |
const dataToSend = {
|
145 |
itemName: itemName,
|
146 |
+
itemPrice: itemPrice, // Send price as string
|
147 |
itemImage: itemImage,
|
148 |
addons: [], // Example: No addons for now
|
149 |
instructions: "", // Example: No instructions for now
|
|
|
171 |
});
|
172 |
}
|
173 |
|
|
|
174 |
</script>
|
175 |
|
176 |
</body>
|