mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06: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');
|
return new Error('Missing cartId');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
console.log('removeItem lineId', lineId);
|
||||||
//await removeFromCart(cartId, [lineId]);
|
//await removeFromCart(cartId, [lineId]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return new Error('Error removing item', { cause: e });
|
return new Error('Error removing item', { cause: e });
|
||||||
@ -48,6 +49,9 @@ export const updateItemQuantity = async ({
|
|||||||
return new Error('Missing cartId');
|
return new Error('Missing cartId');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
console.log('lineId', lineId);
|
||||||
|
console.log('variantId', variantId);
|
||||||
|
console.log('quantity', quantity);
|
||||||
// await updateCart(cartId, [
|
// await updateCart(cartId, [
|
||||||
// {
|
// {
|
||||||
// id: lineId,
|
// id: lineId,
|
||||||
|
@ -33,7 +33,8 @@ export function AddToCart({
|
|||||||
if (variant) {
|
if (variant) {
|
||||||
setSelectedVariantId(variant.id);
|
setSelectedVariantId(variant.id);
|
||||||
}
|
}
|
||||||
}, [searchParams, variants, setSelectedVariantId]);
|
console.log('selectedVariantId', selectedVariantId);
|
||||||
|
}, [searchParams, variants, setSelectedVariantId, selectedVariantId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
@ -50,7 +50,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
|
|||||||
// Always update the quantity reference
|
// Always update the quantity reference
|
||||||
quantityRef.current = cart.totalQuantity;
|
quantityRef.current = cart.totalQuantity;
|
||||||
}
|
}
|
||||||
}, [isOpen, cart.totalQuantity, quantityRef]);
|
}, [isOpen, cart, quantityRef]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -25,7 +25,8 @@ function getApiClient(cartId?: string) {
|
|||||||
apiType: getApiType(),
|
apiType: getApiType(),
|
||||||
contextToken: cartId,
|
contextToken: cartId,
|
||||||
onContextChanged(newContextToken: string) {
|
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