mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 16:07:01 +00:00
variants
This commit is contained in:
parent
2b9fe58832
commit
8b0883d619
@ -5,29 +5,30 @@ import { cookies } from 'next/headers';
|
|||||||
|
|
||||||
export const addItem = async (variantId: string | undefined): Promise<String | undefined> => {
|
export const addItem = async (variantId: string | undefined): Promise<String | undefined> => {
|
||||||
// let cartId = cookies().get('cartId')?.value;
|
// let cartId = cookies().get('cartId')?.value;
|
||||||
// let cart;
|
let cartId = undefined;
|
||||||
//
|
let cart;
|
||||||
// if (cartId) {
|
|
||||||
// cart = await getCart(cartId);
|
if (cartId) {
|
||||||
// }
|
cart = await getCart(cartId);
|
||||||
//
|
}
|
||||||
// if (!cartId || !cart) {
|
|
||||||
// cart = await createCart();
|
if (!cartId || !cart) {
|
||||||
// cartId = cart.id;
|
cart = await createCart();
|
||||||
// // TODO: this is not working under older Next.js versions
|
cartId = cart.id;
|
||||||
// // cookies().set('cartId', cartId);
|
// TODO: this is not working under older Next.js versions
|
||||||
// }
|
// cookies().set('cartId', cartId);
|
||||||
//
|
}
|
||||||
// if (!variantId) {
|
|
||||||
// return 'Missing product variant ID';
|
if (!variantId) {
|
||||||
// }
|
return 'Missing product variant ID';
|
||||||
//
|
}
|
||||||
// try {
|
|
||||||
// await addToCart(cartId, [{ merchandiseId: variantId, quantity: 1 }]);
|
try {
|
||||||
// } catch (e) {
|
await addToCart(cartId, [{ merchandiseId: variantId, quantity: 1 }]);
|
||||||
// return 'Error adding item to cart';
|
} catch (e) {
|
||||||
// }
|
return 'Error adding item to cart';
|
||||||
return undefined;
|
}
|
||||||
|
// return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeItem = async (lineId: string): Promise<String | undefined> => {
|
export const removeItem = async (lineId: string): Promise<String | undefined> => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user