mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
fix: remove line items when 0
This commit is contained in:
@@ -14,7 +14,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) {
|
||||
setRemoving(true);
|
||||
|
||||
console.log(item.id);
|
||||
const response = await fetch(`/api/cart?lineId=${item.id}`, {
|
||||
const response = await fetch(`/api/cart?lineItemId=${item.id}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
|
@@ -20,13 +20,18 @@ export default function EditItemQuantityButton({
|
||||
async function handleEdit() {
|
||||
setEditing(true);
|
||||
|
||||
const response = await fetch(`/api/cart`, {
|
||||
method: type === 'minus' && item.quantity - 1 === 0 ? 'DELETE' : 'PUT',
|
||||
body: JSON.stringify({
|
||||
lineId: item.id,
|
||||
variantId: item.merchandise.id,
|
||||
quantity: type === 'plus' ? item.quantity + 1 : item.quantity - 1
|
||||
})
|
||||
const method = type === 'minus' && item.quantity - 1 === 0 ? 'DELETE' : 'PUT';
|
||||
const url = method === 'PUT' ? '/api/cart' : `/api/cart?lineItemId=${item.id}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
body:
|
||||
method === 'PUT'
|
||||
? JSON.stringify({
|
||||
lineItemId: item.id,
|
||||
quantity: type === 'plus' ? item.quantity + 1 : item.quantity - 1
|
||||
})
|
||||
: null
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
Reference in New Issue
Block a user