mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 22:16:58 +00:00
fix: cart bugs
This commit is contained in:
parent
834e6bdff3
commit
f739c891b0
@ -20,7 +20,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) {
|
||||
|
||||
setRemoving(true);
|
||||
|
||||
removeFromCart(cartId, item.id);
|
||||
await removeFromCart(cartId, item.id);
|
||||
|
||||
setRemoving(false);
|
||||
|
||||
|
@ -30,12 +30,12 @@ export default function EditItemQuantityButton({
|
||||
const method = type === 'minus' && item.quantity - 1 === 0 ? 'remove' : 'update';
|
||||
|
||||
method === 'update' &&
|
||||
updateCart(cartId, {
|
||||
(await updateCart(cartId, {
|
||||
lineItemId: item.id,
|
||||
quantity: type === 'plus' ? item.quantity + 1 : item.quantity - 1
|
||||
});
|
||||
}));
|
||||
|
||||
method === 'remove' && removeFromCart(cartId, item.id);
|
||||
method === 'remove' && (await removeFromCart(cartId, item.id));
|
||||
|
||||
setEditing(false);
|
||||
|
||||
|
@ -38,14 +38,12 @@ export function AddToCart({
|
||||
const isMutating = adding || isPending;
|
||||
|
||||
async function handleAdd() {
|
||||
if (!availableForSale || !selectedVariantId) return;
|
||||
if (!availableForSale || !variants[0]) return;
|
||||
|
||||
setAdding(true);
|
||||
|
||||
console.log({ cookie });
|
||||
|
||||
addToCart(cookie.cartId, {
|
||||
variantId: selectedVariantId,
|
||||
await addToCart(cookie.cartId, {
|
||||
variantId: selectedVariantId || variants[0].id,
|
||||
quantity: 1
|
||||
});
|
||||
|
||||
|
@ -65,7 +65,7 @@ export default async function medusaRequest(
|
||||
|
||||
const reshapeCart = (cart: MedusaCart): Cart => {
|
||||
const lines = cart?.items?.map((item) => reshapeLineItem(item)) || [];
|
||||
const totalQuantity = lines.length;
|
||||
const totalQuantity = lines.reduce((a, b) => a + b.quantity, 0);
|
||||
const checkoutUrl = '/';
|
||||
const currencyCode = cart.region?.currency_code.toUpperCase() || 'USD';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user