Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +32 -11
templates/cart.html
CHANGED
@@ -177,19 +177,22 @@
|
|
177 |
</div>
|
178 |
|
179 |
<!-- Suggestions Section -->
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
<
|
185 |
-
|
186 |
-
<div>
|
187 |
-
|
|
|
|
|
|
|
188 |
</div>
|
189 |
-
|
190 |
</div>
|
191 |
-
|
192 |
-
|
193 |
</div>
|
194 |
|
195 |
<script>
|
@@ -399,6 +402,24 @@
|
|
399 |
})
|
400 |
.catch(err => console.error("Error adding item to cart:", err));
|
401 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
|
403 |
|
404 |
</script>
|
|
|
177 |
</div>
|
178 |
|
179 |
<!-- Suggestions Section -->
|
180 |
+
{% if suggestions %}
|
181 |
+
<div class="suggestion-section">
|
182 |
+
<h5>Complete Your Meal</h5>
|
183 |
+
{% for suggestion in suggestions %}
|
184 |
+
<div class="suggestion-item">
|
185 |
+
<img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
|
186 |
+
<div>
|
187 |
+
<div>{{ suggestion.Name }}</div>
|
188 |
+
<div class="text-muted">₹{{ suggestion.Price__c }}</div>
|
189 |
+
</div>
|
190 |
+
<button class="add-back-button" onclick="addSuggestion('{{ suggestion.Id }}')">Add</button>
|
191 |
</div>
|
192 |
+
{% endfor %}
|
193 |
</div>
|
194 |
+
{% endif %}
|
195 |
+
|
196 |
</div>
|
197 |
|
198 |
<script>
|
|
|
402 |
})
|
403 |
.catch(err => console.error("Error adding item to cart:", err));
|
404 |
}
|
405 |
+
function addSuggestion(itemId) {
|
406 |
+
fetch(`/cart/add_suggestion/${itemId}`, {
|
407 |
+
method: 'POST',
|
408 |
+
headers: { 'Content-Type': 'application/json' },
|
409 |
+
body: JSON.stringify({})
|
410 |
+
})
|
411 |
+
.then(response => response.json())
|
412 |
+
.then(data => {
|
413 |
+
if (data.success) {
|
414 |
+
alert('Item added to cart!');
|
415 |
+
location.reload();
|
416 |
+
} else {
|
417 |
+
alert(data.error);
|
418 |
+
}
|
419 |
+
})
|
420 |
+
.catch(err => console.error('Error adding suggestion:', err));
|
421 |
+
}
|
422 |
+
|
423 |
|
424 |
|
425 |
</script>
|