Claims
Mutations listed here are used to send requests to the Admin Order API Routes related to claims.
All hooks listed require user authentication.
A claim represents a return or replacement request of order items. It allows refunding the customer or replacing some or all of its order items with new items.
Related Guide: How to manage claims.
Mutations
useAdminCreateClaim
This hook creates a claim for an order. If a return shipping method is specified, a return will also be created and associated with the claim. If the claim's type is refund
,
the refund is processed as well.
Example
import React from "react"
import { useAdminCreateClaim } from "medusa-react"
type Props = {
orderId: string
}
const CreateClaim = ({ orderId }: Props) => {
const createClaim = useAdminCreateClaim(orderId)
// ...
const handleCreate = (itemId: string) => {
createClaim.mutate({
type: "refund",
claim_items: [
{
item_id: itemId,
quantity: 1,
},
],
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default CreateClaim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
The details of the claim to be created.
Mutation Function Returned Data
The order's details.
useAdminUpdateClaim
This hook updates a claim's details.
Example
import React from "react"
import { useAdminUpdateClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const updateClaim = useAdminUpdateClaim(orderId)
// ...
const handleUpdate = () => {
updateClaim.mutate({
claim_id: claimId,
no_notification: false
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
Mutation Function Returned Data
The order's details.
useAdminCancelClaim
This hook cancels a claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled, of if its associated return hasn't been canceled.
Example
import React from "react"
import { useAdminCancelClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const cancelClaim = useAdminCancelClaim(orderId)
// ...
const handleCancel = () => {
cancelClaim.mutate(claimId)
}
// ...
}
export default Claim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
string
stringRequiredMutation Function Returned Data
The order's details.
useAdminFulfillClaim
This hook creates a Fulfillment for a Claim, and change its fulfillment status to partially_fulfilled
or fulfilled
depending on whether all the items were fulfilled.
It may also change the status to requires_action
if any actions are required.
Example
import React from "react"
import { useAdminFulfillClaim } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const fulfillClaim = useAdminFulfillClaim(orderId)
// ...
const handleFulfill = () => {
fulfillClaim.mutate({
claim_id: claimId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
The details of the claim's fulfillment.
Mutation Function Returned Data
The order's details.
useAdminCancelClaimFulfillment
This hook cancels a claim's fulfillment and change its fulfillment status to canceled
.
Example
import React from "react"
import { useAdminCancelClaimFulfillment } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const cancelFulfillment = useAdminCancelClaimFulfillment(
orderId
)
// ...
const handleCancel = (fulfillmentId: string) => {
cancelFulfillment.mutate({
claim_id: claimId,
fulfillment_id: fulfillmentId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
The cancelation details.
Mutation Function Returned Data
The order's details.
useAdminCreateClaimShipment
This hook creates a shipment for the claim and mark its fulfillment as shipped. If the shipment is created successfully, this changes the claim's fulfillment status
to either partially_shipped
or shipped
, depending on whether all the items were shipped.
Example
import React from "react"
import { useAdminCreateClaimShipment } from "medusa-react"
type Props = {
orderId: string
claimId: string
}
const Claim = ({ orderId, claimId }: Props) => {
const createShipment = useAdminCreateClaimShipment(orderId)
// ...
const handleCreateShipment = (fulfillmentId: string) => {
createShipment.mutate({
claim_id: claimId,
fulfillment_id: fulfillmentId,
}, {
onSuccess: ({ order }) => {
console.log(order.claims)
}
})
}
// ...
}
export default Claim
Hook Parameters
orderId
stringRequiredMutation Function Parameters
claim_id
stringRequired