diff --git a/app/product/[...handle]/page.tsx b/app/product/[...handle]/page.tsx index ceb36da7e..4c54e2dfd 100644 --- a/app/product/[...handle]/page.tsx +++ b/app/product/[...handle]/page.tsx @@ -104,7 +104,11 @@ export default async function ProductPage({ params }: { params: { handle: string ) : null} - + diff --git a/components/cart/actions.ts b/components/cart/actions.ts index 35b9e9653..45e1b6053 100644 --- a/components/cart/actions.ts +++ b/components/cart/actions.ts @@ -2,7 +2,7 @@ import { ApiClientError } from '@shopware/api-client'; import { getApiClient } from 'lib/shopware/api'; -import { ExtendedCart } from 'lib/shopware/api-extended'; +import { ExtendedCart, ExtendedLineItem } from 'lib/shopware/api-extended'; import { cookies } from 'next/headers'; export const fetchCart = async function (cartId?: string): Promise { @@ -29,12 +29,23 @@ export const addItem = async (variantId: string | undefined): Promise item.id === variantId) as + | ExtendedLineItem + | undefined; + if (itemInCart && itemInCart.quantity) { + quantity = itemInCart.quantity + 1; + } + apiClient.invoke('addLineItem post /checkout/cart/line-item', { items: [ { id: variantId, - quantity: 1, + quantity: quantity, referencedId: variantId, type: 'product' } diff --git a/components/cart/modal.tsx b/components/cart/modal.tsx index 07294640a..0d8bc29f6 100644 --- a/components/cart/modal.tsx +++ b/components/cart/modal.tsx @@ -39,7 +39,6 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU }, [setCookie, cartIdUpdated, cart.id]); useEffect(() => { - console.warn('cart modal', cart); // Open cart modal when when quantity changes. if (cart.totalQuantity !== quantityRef.current) { // But only if it's not already open (quantity also changes when editing items in cart).