feat(poc): working on addToCart

This commit is contained in:
Björn Meyer 2023-07-21 08:43:01 +02:00
parent 59b9a9d1b7
commit 5545375527
4 changed files with 9 additions and 3 deletions

View File

@ -27,6 +27,7 @@ export const removeItem = async (lineId: string): Promise<Error | undefined> =>
return new Error('Missing cartId');
}
try {
console.log('removeItem lineId', lineId);
//await removeFromCart(cartId, [lineId]);
} catch (e) {
return new Error('Error removing item', { cause: e });
@ -48,6 +49,9 @@ export const updateItemQuantity = async ({
return new Error('Missing cartId');
}
try {
console.log('lineId', lineId);
console.log('variantId', variantId);
console.log('quantity', quantity);
// await updateCart(cartId, [
// {
// id: lineId,

View File

@ -33,7 +33,8 @@ export function AddToCart({
if (variant) {
setSelectedVariantId(variant.id);
}
}, [searchParams, variants, setSelectedVariantId]);
console.log('selectedVariantId', selectedVariantId);
}, [searchParams, variants, setSelectedVariantId, selectedVariantId]);
return (
<button

View File

@ -50,7 +50,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
// Always update the quantity reference
quantityRef.current = cart.totalQuantity;
}
}, [isOpen, cart.totalQuantity, quantityRef]);
}, [isOpen, cart, quantityRef]);
return (
<>

View File

@ -25,7 +25,8 @@ function getApiClient(cartId?: string) {
apiType: getApiType(),
contextToken: cartId,
onContextChanged(newContextToken: string) {
//cookies().set('sw-context-token', newContextToken);
cookies().set('sw-context-token', newContextToken);
console.log('newContextToken', newContextToken);
}
});