mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 05:56:59 +00:00
feat(poc): working on addToCart
This commit is contained in:
parent
59b9a9d1b7
commit
5545375527
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
<>
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user