Spaces:
Sleeping
Sleeping
Update templates/order_history.html
Browse files- templates/order_history.html +49 -44
templates/order_history.html
CHANGED
@@ -81,38 +81,43 @@
|
|
81 |
<div class="order-history-container">
|
82 |
<h4 class="mb-4 text-center">Your Order History</h4>
|
83 |
|
84 |
-
{% if
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
</div>
|
109 |
-
{% endfor %}
|
110 |
-
{% endfor %}
|
111 |
-
{% else %}
|
112 |
-
<p class="text-center">No order History Available </p>
|
113 |
-
|
114 |
-
|
115 |
-
{% endif %}
|
116 |
</div>
|
117 |
</div>
|
118 |
|
@@ -126,28 +131,28 @@
|
|
126 |
const category = button.dataset.category; // Get category from data-category attribute
|
127 |
const section = button.dataset.section; // Get section from data-section attribute
|
128 |
console.log(itemPrice)
|
129 |
-
|
130 |
-
|
|
|
|
|
131 |
if (!itemPrice || !itemImage || !itemName || !category || !section) {
|
132 |
alert('Missing required item data.');
|
133 |
return;
|
134 |
}
|
135 |
|
136 |
-
// Ensure the price is
|
137 |
-
const itemPriceStr = String(itemPrice); // Explicitly convert to string
|
138 |
|
139 |
-
// Create a JSON object to send to the server
|
140 |
const dataToSend = {
|
141 |
-
itemName: itemName,
|
142 |
-
itemPrice: itemPriceStr,
|
143 |
-
itemImage: itemImage,
|
144 |
-
addons: [],
|
145 |
-
instructions: "",
|
146 |
-
category: category,
|
147 |
-
section: section
|
148 |
};
|
149 |
|
150 |
-
// Send the data to the server via a POST request
|
151 |
fetch('/cart/add', {
|
152 |
method: 'POST',
|
153 |
headers: {
|
|
|
81 |
<div class="order-history-container">
|
82 |
<h4 class="mb-4 text-center">Your Order History</h4>
|
83 |
|
84 |
+
{% if orders %}
|
85 |
+
{% for order in orders %}
|
86 |
+
<h5>Order on: {{ order.CreatedDate }}</h5>
|
87 |
+
|
88 |
+
{% for line in order.Order_Details__c.split('\n') %}
|
89 |
+
{% set item_parts = line.split('|') %}
|
90 |
+
|
91 |
+
<!-- Extract image URL from the Order_Details string -->
|
92 |
+
{% set image_url = item_parts[4].strip().split('Image: ')[-1] %}
|
93 |
+
|
94 |
+
<div class="order-item">
|
95 |
+
<!-- Display Item Image -->
|
96 |
+
<img src="{{ image_url }}" alt="{{ item_parts[0].strip() }}"
|
97 |
+
onerror="this.src='/static/placeholder.jpg';">
|
98 |
+
|
99 |
+
<div class="order-item-details">
|
100 |
+
<div class="order-item-title">{{ item_parts[0].strip() }}</div>
|
101 |
+
<div><small class="text-muted">Quantity: {{ item_parts[1].strip() }}</small></div>
|
102 |
+
<div><small class="text-muted">Add-Ons: {{ item_parts[2].strip() }}</small></div>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<button class="reorder-button"
|
106 |
+
onclick="addToCart('{{ item_parts[0].strip() }}')"
|
107 |
+
id="{{ item_parts[0].strip() }}"
|
108 |
+
data-price="{{ item_parts[3].strip().replace('Price:', '') }}"
|
109 |
+
data-image="{{ image_url }}"
|
110 |
+
data-category="Main Course"
|
111 |
+
data-section="Reordered Items">
|
112 |
+
Reorder
|
113 |
+
</button>
|
114 |
+
</div>
|
115 |
+
{% endfor %}
|
116 |
+
{% endfor %}
|
117 |
+
{% else %}
|
118 |
+
<p class="text-center">No order History Available</p>
|
119 |
+
{% endif %}
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
</div>
|
122 |
</div>
|
123 |
|
|
|
131 |
const category = button.dataset.category; // Get category from data-category attribute
|
132 |
const section = button.dataset.section; // Get section from data-section attribute
|
133 |
console.log(itemPrice)
|
134 |
+
console.log(itemImage)
|
135 |
+
console.log(itemName)
|
136 |
+
|
137 |
+
|
138 |
if (!itemPrice || !itemImage || !itemName || !category || !section) {
|
139 |
alert('Missing required item data.');
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
+
// Ensure the price is treated as a string
|
144 |
+
const itemPriceStr = String(itemPrice); // Explicitly convert price to string
|
145 |
|
|
|
146 |
const dataToSend = {
|
147 |
+
itemName: itemName,
|
148 |
+
itemPrice: itemPriceStr,
|
149 |
+
itemImage: itemImage,
|
150 |
+
addons: [],
|
151 |
+
instructions: "",
|
152 |
+
category: category,
|
153 |
+
section: section
|
154 |
};
|
155 |
|
|
|
156 |
fetch('/cart/add', {
|
157 |
method: 'POST',
|
158 |
headers: {
|