Rammohan0504 commited on
Commit
f029c47
·
verified ·
1 Parent(s): 1f2fbe3

Update templates/order_history.html

Browse files
Files changed (1) hide show
  1. templates/order_history.html +11 -15
templates/order_history.html CHANGED
@@ -127,33 +127,28 @@
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; // `const` is fine because it won't change
131
- const category = button.dataset.category; // `const` is fine
132
- const section = button.dataset.section; // `const` is fine
133
 
 
 
134
 
135
- console.log(itemPrice)
136
- console.log(itemImage)
137
- console.log(category)
138
- console.log(section)
139
- // Explicitly convert price to string before concatenation
140
- let itemPriceStr = String(itemPrice); // Convert price to string
141
- console.log(itemPriceStr)
142
- if (!itemPriceStr || !itemImage || !itemName || !category || !section) {
143
  alert('Missing required item data.');
144
  return;
145
  }
146
 
 
147
  const dataToSend = {
148
  itemName: itemName,
149
- itemPrice: itemPriceStr, // Ensure itemPrice is a string here
150
  itemImage: itemImage,
151
- addons: [],
152
- instructions: "",
153
  category: category,
154
  section: section
155
  };
156
- console.log(dataToSend)
157
 
158
  fetch('/cart/add', {
159
  method: 'POST',
@@ -175,6 +170,7 @@ console.log(itemPriceStr)
175
  });
176
  }
177
 
 
178
  </script>
179
 
180
  </body>
 
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 sent as a string (e.g., "$16.0")
135
+ itemPrice = String(itemPrice); // Convert item price to a string (e.g., "$16.0")
136
 
137
+ if (!itemPrice || !itemImage || !itemName || !category || !section) {
 
 
 
 
 
 
 
138
  alert('Missing required item data.');
139
  return;
140
  }
141
 
142
+ // Create a data object to send to the server
143
  const dataToSend = {
144
  itemName: itemName,
145
+ itemPrice: itemPrice, // Send price as string
146
  itemImage: itemImage,
147
+ addons: [], // Example: No addons for now
148
+ instructions: "", // Example: No instructions for now
149
  category: category,
150
  section: section
151
  };
 
152
 
153
  fetch('/cart/add', {
154
  method: 'POST',
 
170
  });
171
  }
172
 
173
+
174
  </script>
175
 
176
  </body>