diff --git a/framework/saleor/cart/use-remove-item.tsx b/framework/saleor/cart/use-remove-item.tsx index 8db38eac2..af9cc87a5 100644 --- a/framework/saleor/cart/use-remove-item.tsx +++ b/framework/saleor/cart/use-remove-item.tsx @@ -16,7 +16,7 @@ import { checkoutToCart, } from '../utils' import { Cart, LineItem } from '../types' -import { Mutation, MutationCheckoutLineItemsRemoveArgs } from '../schema' +import { Mutation, MutationCheckoutLineDeleteArgs } from '../schema' export type RemoveItemFn = T extends LineItem ? (input?: RemoveItemInput) => Promise @@ -37,11 +37,14 @@ export const handler = { options, fetch, }: HookFetcherContext) { - const data = await fetch({ + const data = await fetch({ ...options, - variables: { checkoutId: getCheckoutId(), lineItemIds: [itemId] }, + variables: { + checkoutId: getCheckoutId().checkoutId, + lineId: itemId + }, }) - return checkoutToCart(data.checkoutLineItemsRemove) + return checkoutToCart(data.checkoutLinesUpdate) }, useHook: ({ fetch, diff --git a/framework/saleor/cart/use-update-item.tsx b/framework/saleor/cart/use-update-item.tsx index 49dd6be14..0361bdd97 100644 --- a/framework/saleor/cart/use-update-item.tsx +++ b/framework/saleor/cart/use-update-item.tsx @@ -15,7 +15,7 @@ import { handler as removeItemHandler } from './use-remove-item' import type { Cart, LineItem, UpdateCartItemBody } from '../types' import { checkoutToCart } from '../utils' import { getCheckoutId, checkoutLineItemUpdateMutation } from '../utils' -import { Mutation, MutationCheckoutLineItemsUpdateArgs } from '../schema' +import { Mutation, MutationCheckoutLinesUpdateArgs } from '../schema' export type UpdateItemInput = T extends LineItem ? Partial> @@ -46,23 +46,25 @@ export const handler = { message: 'The item quantity has to be a valid integer', }) } - const { checkoutLineItemsUpdate } = await fetch< + + const checkoutId = getCheckoutId().checkoutId; + const { checkoutLinesUpdate } = await fetch< Mutation, - MutationCheckoutLineItemsUpdateArgs + MutationCheckoutLinesUpdateArgs >({ ...options, variables: { - checkoutId: getCheckoutId(), + checkoutId, lineItems: [ { - id: itemId, + variantId: item.variantId, quantity: item.quantity, }, ], }, }) - return checkoutToCart(checkoutLineItemsUpdate) + return checkoutToCart(checkoutLinesUpdate) }, useHook: ({ fetch, diff --git a/framework/saleor/utils/mutations/checkout-line-item-remove.ts b/framework/saleor/utils/mutations/checkout-line-item-remove.ts index 548130139..1eda0e86c 100644 --- a/framework/saleor/utils/mutations/checkout-line-item-remove.ts +++ b/framework/saleor/utils/mutations/checkout-line-item-remove.ts @@ -1,19 +1,19 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' const checkoutLineItemRemoveMutation = /* GraphQL */ ` - mutation checkoutLineItemRemove($checkoutId: ID!, $lineItemIds: [ID!]!) { - checkoutLineItemsRemove( + mutation checkoutLineItemRemove($checkoutId: ID!, $lineId: ID!) { + checkoutLineDelete( checkoutId: $checkoutId - lineItemIds: $lineItemIds + lineId: $lineId ) { - checkoutUserErrors { + errors { code field message } - # checkout { - # ${checkoutDetailsFragment} - # } + checkout { + ${checkoutDetailsFragment} + } } } ` diff --git a/framework/saleor/utils/mutations/checkout-line-item-update.ts b/framework/saleor/utils/mutations/checkout-line-item-update.ts index 85c5cac5b..958921d15 100644 --- a/framework/saleor/utils/mutations/checkout-line-item-update.ts +++ b/framework/saleor/utils/mutations/checkout-line-item-update.ts @@ -1,8 +1,8 @@ import { checkoutDetailsFragment } from '../queries/get-checkout-query' const checkoutLineItemUpdateMutation = /* GraphQL */ ` - mutation checkoutLineItemUpdate($checkoutId: ID!, $lineItems: [CheckoutLineItemUpdateInput!]!) { - checkoutLinesUpdate(checkoutId: $checkoutId, lineItems: $lineItems) { + mutation checkoutLineItemUpdate($checkoutId: ID!, $lineItems: [CheckoutLineInput!]!) { + checkoutLinesUpdate(checkoutId: $checkoutId, lines: $lineItems) { errors { code field