From ccd48f575c47ccf0b2f8d2c2c412cd2aac105478 Mon Sep 17 00:00:00 2001 From: w3bdesign <45217974+w3bdesign@users.noreply.github.com> Date: Mon, 30 Jun 2025 04:11:41 +0200 Subject: [PATCH 1/2] Cart quantity change --- components/Cart/CartContents.vue | 15 +++++++ components/Cart/CartItem.vue | 31 +++++++++++-- components/common/QuantityInput.vue | 68 +++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 components/common/QuantityInput.vue diff --git a/components/Cart/CartContents.vue b/components/Cart/CartContents.vue index 8450799a..0150d7c5 100644 --- a/components/Cart/CartContents.vue +++ b/components/Cart/CartContents.vue @@ -15,6 +15,7 @@ :key="product.key" :product="product" @remove="handleRemoveProduct" + @update-quantity="handleUpdateQuantity" /> @@ -73,6 +74,20 @@ onMounted(async () => { isLoading.value = false; } }); + +/** + * Handles updating the quantity of a cart item. + * + * @param {{ key: string, quantity: number }} payload + */ +const handleUpdateQuantity = async ({ key, quantity }) => { + try { + await cart.updateCartItemQuantity(key, quantity); + } catch (error) { + console.error("Error updating cart item quantity:", error); + // Optionally, add user notification here + } +};