Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit b66e2620 authored by 65160381's avatar 65160381
Browse files

10.2

parent 2a4c494a
No related branches found
No related tags found
No related merge requests found
Pipeline #632 passed with warnings
......@@ -57,7 +57,10 @@
<label for="order-products">Products:</label>
<ul id="order-products">
${order.products.map(product => `
<li>${product.name} - $${product.price} x ${product.quantity}</li>
<li>
${product.name} - $${product.price} x ${product.quantity}
<input type="number" value="${product.quantity}" min="1" id="product-quantity-${product.id}" />
</li>
`).join('')}
</ul>
</div>
......@@ -81,6 +84,15 @@
const status = document.getElementById('order-status').value;
const shippingAddress = document.getElementById('order-shipping-address').value;
// Get updated quantities of each product
const updatedProducts = [];
const productsList = document.querySelectorAll('#order-products li');
productsList.forEach(productItem => {
const productId = productItem.dataset.productId;
const quantity = document.getElementById(`product-quantity-${productId}`).value;
updatedProducts.push({ productId, quantity });
});
try {
const response = await fetch(`/api/orders/${orderId}`, {
method: 'PUT',
......@@ -89,7 +101,8 @@
},
body: JSON.stringify({
status: status,
shipping_address: shippingAddress
shipping_address: shippingAddress,
products: updatedProducts
})
});
......@@ -109,5 +122,6 @@
// Load order details when page loads
window.onload = loadOrderDetails;
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment