Update templates/order_history.html
Browse files- templates/order_history.html +9 -15
templates/order_history.html
CHANGED
@@ -126,28 +126,22 @@
|
|
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 |
-
|
131 |
-
|
132 |
-
|
133 |
-
console.log(itemPrice)
|
134 |
-
console.log(itemImage)
|
135 |
-
console.log(itemName)
|
136 |
-
|
137 |
-
itemPriceStr = String(itemPrice); // Convert price to string
|
138 |
|
139 |
-
|
140 |
-
|
|
|
|
|
141 |
alert('Missing required item data.');
|
142 |
return;
|
143 |
}
|
144 |
|
145 |
-
// Ensure the price is treated as a string
|
146 |
-
const itemPriceStr = String(itemPrice); // Explicitly convert price to string
|
147 |
-
|
148 |
const dataToSend = {
|
149 |
itemName: itemName,
|
150 |
-
itemPrice: itemPriceStr,
|
151 |
itemImage: itemImage,
|
152 |
addons: [],
|
153 |
instructions: "",
|
|
|
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; // Use `let` here because we may update the value
|
130 |
+
let itemImage = button.dataset.image; // `const` is fine because it won't change
|
131 |
+
let category = button.dataset.category; // `const` is fine
|
132 |
+
let section = button.dataset.section; // `const` is fine
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
+
// Explicitly convert price to string if it's a number (important for concatenation)
|
135 |
+
let itemPriceStr = String(itemPrice); // Convert price to string after retrieving the value
|
136 |
+
|
137 |
+
if (!itemPriceStr || !itemImage || !itemName || !category || !section) {
|
138 |
alert('Missing required item data.');
|
139 |
return;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
142 |
const dataToSend = {
|
143 |
itemName: itemName,
|
144 |
+
itemPrice: itemPriceStr, // Ensure itemPrice is a string here
|
145 |
itemImage: itemImage,
|
146 |
addons: [],
|
147 |
instructions: "",
|