Returns
Mutations listed here are used to send requests to the Store Return API Routes.
A return can be created by a customer to return items in an order.
Related Guide: How to create a return in a storefront.
Mutations
useCreateReturn
This hook creates a return for an order. If a return shipping method is specified, the return is automatically fulfilled.
Example
import React from "react"
import { useCreateReturn } from "medusa-react"
type CreateReturnData = {
  items: {
    item_id: string,
    quantity: number
  }[]
  return_shipping: {
    option_id: string
  }
}
type Props = {
  orderId: string
}
const CreateReturn = ({ orderId }: Props) => {
  const createReturn = useCreateReturn()
  // ...
  const handleCreate = (data: CreateReturnData) => {
    createReturn.mutate({
      ...data,
      order_id: orderId
    }, {
      onSuccess: ({ return: returnData }) => {
        console.log(returnData.id)
      }
    })
  }
  // ...
}
export default CreateReturn
Mutation Function Parameters
The details of the return to create.
Mutation Function Returned Data
The return's details.
Was this section helpful?