Skip to content

Commit

Permalink
✨ add item route
Browse files Browse the repository at this point in the history
  • Loading branch information
DuvCharles committed Nov 21, 2023
1 parent ee5bd59 commit 027b8e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/sylius/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ export const getCart = async (cartId: string): Promise<Cart> => {
const syliusCart = data.body;
return normalizeCart(syliusCart);
};
export const addToCart = (cartId: string | undefined, payload: AddToCartPayload[]) => {
syliusRequest(REST_METHODS.PUT, `/orders/${cartId}/items`, payload[0]);
return {};
export const addToCart = async (cartId: string | undefined, payload: AddToCartPayload[]) => {
await syliusRequest(REST_METHODS.POST, `/orders/${cartId}/items`, { productVariant: payload[0]?.merchandiseId, quantity: payload[0]?.quantity });
};
export const removeFromCart = () => {};
export const updateCart = () => {};
Expand Down
3 changes: 2 additions & 1 deletion lib/sylius/normalizer/product-normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const normalizeProduct = (product: SyliusProduct): Product => ({
title: product.name,
description: product.shortDescription
},
variants: product.variants.map((variant) => normalizeProductVariant(variant)),
// dont need varaints when serializing fort cart
variants: product.variants ? product.variants.map((variant) => normalizeProductVariant(variant)) : [],
images: product.images.map((image) => normalizeProductImage(image)),
id: product.id.toString(),
handle: product.slug,
Expand Down

0 comments on commit 027b8e5

Please sign in to comment.