Rammohan0504 commited on
Commit
ef267c6
·
verified ·
1 Parent(s): b6a6f63

Update templates/order_history.html

Browse files
Files changed (1) hide show
  1. 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 order %}
85
- {% for line in order.Order_Details__c.split('\n') %}
86
- {% set item_parts = line.split('|') %}
87
- <div class="order-item">
88
- <!-- Item Image -->
89
- <img src="{{ item_parts[4].strip().replace('Image:', '') }}"
90
- alt="{{ item_parts[0].strip() }}"
91
- onerror="this.src='/static/placeholder.jpg';">
92
-
93
-
94
- <div class="order-item-details">
95
- <div class="order-item-title">{{ item_parts[0].strip() }}</div>
96
- <div><small class="text-muted">Quantity: {{ item_parts[1].strip() }}</small></div>
97
- </div>
98
- <button class="reorder-button"
99
- onclick="addToCart('{{ item_parts[0].strip() }}')"
100
- id="{{ item_parts[0].strip() }}"
101
- data-price="{{ item_parts[3].strip().replace('Price:', '') }}"
102
- data-image="{{ item_parts[4].strip().replace('Image:', '') }}"
103
- data-category="Main Course" <!-- Example category -->
104
- Reorder
105
- </button>
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
- console.log(itemImage)
130
- console.log(itemName)
 
 
131
  if (!itemPrice || !itemImage || !itemName || !category || !section) {
132
  alert('Missing required item data.');
133
  return;
134
  }
135
 
136
- // Ensure the price is explicitly treated as a string
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, // Item name to be reordered
142
- itemPrice: itemPriceStr, // Price as a string
143
- itemImage: itemImage, // Image URL of the item
144
- addons: [], // List of add-ons (empty for now)
145
- instructions: "", // Instructions for the item (empty for now)
146
- category: category, // Category of the item
147
- section: section // Section of the item
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: {