Skip to content

Commit

Permalink
Fix adding variants to cart
Browse files Browse the repository at this point in the history
  • Loading branch information
lhvy committed Jun 21, 2024
1 parent 0a38d5a commit 385705d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pages/merch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const getServerSideProps = async () => {
product.price;
});

variants.forEach((variant: Variant) => {
variant.price =
prices.find((price: Price) => price.id === variant.price.id) ??
variant.price;
});

const repo: Repo = { products, variants };
return { props: { repo } };
};
Expand Down Expand Up @@ -388,7 +394,7 @@ const Merch = ({
name: variant.productName,
images: variant.imageURLs,
},
price: product.price,
price: variant.price,
qty,
});
});
Expand Down
3 changes: 2 additions & 1 deletion scripts/merch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Variant = {
productName: string;
colour: ProductColour;
size: ProductSize;

price: Price;
id: string;
imageURLs: string[];
};
Expand Down Expand Up @@ -121,6 +121,7 @@ export const getAllProductsAndVariants = async (stripe: Stripe) => {
size: toProductSizeMap.get(variantSize) ?? ProductSize.UNKNOWN,
id: variant.id,
imageURLs: variant.images,
price: { id: variant.default_price?.toString() ?? "" },
});
});

Expand Down

0 comments on commit 385705d

Please sign in to comment.