Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi!
I have this Mutation and I am trying to access to the checkoutUserErrors but is just not working or am I doing something wrong?
export const ITEM_REMOVED = gql` mutation checkoutLineItemsRemove($checkoutId: ID!, $lineItemIds: [ID!]!) { checkoutLineItemsRemove( checkoutId: $checkoutId lineItemIds: $lineItemIds ) { checkoutUserErrors { code field message } checkout { ...CheckoutFragment } } } ${CHECKOUT_FRAGMENT} `
const [mutationItemRemoved] = useMutation(ITEM_REMOVED)
// Item removed const itemRemoved = (lineItemId) => { mutationItemRemoved({ variables: { checkoutId: props.checkout.id, lineItemIds: [lineItemId] } }).then(r => { props.updateCheckout(r.data.checkoutLineItemsRemove.checkout) console.log(r.data.checkoutLineItemsRemove.checkout) }).catch(error => { console.log(error.code) }) }
Hi @Agrotitanes
You should start using checkoutLineItemReplace as the former mutation has been depreciated. From there, you will want to call userErrors: https://shopify.dev/docs/storefront-api/reference/mutation/checkoutlineitemsreplace?api[version]=202...
To learn more visit the Shopify Help Center or the Community Blog.
Hi,
After this post I started using checkoutLineItemReplace but I was hoping that you could tell me how to access to those userErrors I mean an example because I don't know how to do that, could you please help me with that?
I am new at this and your documentation doesn't provide a clear example of that and your repositories are not covering this part either.