Spaces:
Sleeping
Sleeping
Update templates/cart.html
Browse files- templates/cart.html +35 -3
templates/cart.html
CHANGED
|
@@ -126,8 +126,18 @@
|
|
| 126 |
<div class="cart-item-details">
|
| 127 |
<div class="cart-item-title">{{ item.Name }}</div>
|
| 128 |
<div class="cart-item-addons">
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
</div>
|
|
|
|
| 131 |
<div class="cart-item-quantity mt-2">
|
| 132 |
<!-- Decrease button -->
|
| 133 |
<button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
|
|
@@ -294,8 +304,30 @@
|
|
| 294 |
})
|
| 295 |
.catch(err => console.error("Error adding item to cart:", err));
|
| 296 |
}
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
</script>
|
| 300 |
|
| 301 |
</body>
|
|
|
|
| 126 |
<div class="cart-item-details">
|
| 127 |
<div class="cart-item-title">{{ item.Name }}</div>
|
| 128 |
<div class="cart-item-addons">
|
| 129 |
+
{% for addon in item.Add_Ons__c.split(";") %}
|
| 130 |
+
<div class="addon-item">
|
| 131 |
+
<span>{{ addon.name }}</span>
|
| 132 |
+
<input type="number" value="{{ addon.quantity }}"
|
| 133 |
+
data-addon-name="{{ addon.name }}" min="1">
|
| 134 |
+
<button onclick="updateAddonQuantity('{{ addon.name }}', this.value, '{{ customer_email }}')">
|
| 135 |
+
Update
|
| 136 |
+
</button>
|
| 137 |
+
</div>
|
| 138 |
+
{% endfor %}
|
| 139 |
</div>
|
| 140 |
+
|
| 141 |
<div class="cart-item-quantity mt-2">
|
| 142 |
<!-- Decrease button -->
|
| 143 |
<button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
|
|
|
|
| 304 |
})
|
| 305 |
.catch(err => console.error("Error adding item to cart:", err));
|
| 306 |
}
|
| 307 |
+
function updateAddonQuantity(addonName, newQuantity, customerEmail) {
|
| 308 |
+
fetch('/cart/update_addon_quantity', {
|
| 309 |
+
method: 'POST',
|
| 310 |
+
headers: {
|
| 311 |
+
'Content-Type': 'application/json',
|
| 312 |
+
},
|
| 313 |
+
body: JSON.stringify({
|
| 314 |
+
email: customerEmail,
|
| 315 |
+
addon_name: addonName,
|
| 316 |
+
quantity: parseInt(newQuantity),
|
| 317 |
+
})
|
| 318 |
+
})
|
| 319 |
+
.then(response => response.json())
|
| 320 |
+
.then(data => {
|
| 321 |
+
if (data.success) {
|
| 322 |
+
alert('Addon quantity updated successfully!');
|
| 323 |
+
} else {
|
| 324 |
+
alert('Error updating addon quantity: ' + data.error);
|
| 325 |
+
}
|
| 326 |
+
})
|
| 327 |
+
.catch(error => {
|
| 328 |
+
console.error('Error:', error);
|
| 329 |
+
});
|
| 330 |
+
}
|
| 331 |
</script>
|
| 332 |
|
| 333 |
</body>
|