Skip to content

feature-return hooks

The components already use these hooks. Reach for them when you build your own UI on the same data. Open a hook for its options and what it returns.

Reading data

useReturnRead a single return by id for the active scope.
import { useReturn } from "@evolve-storefront/feature-return/hooks";

Gated on auth, so it reports isPending (not isLoading) until the client auth context validates. Render the skeleton while isPending; only isSuccess && !data is a real 404.

function useReturn(id: string)

Returns A React Query result: data, isPending, error and the rest.

useReturnableLinesRead the lines of an order that can still be returned, for the request form.
import { useReturnableLines } from "@evolve-storefront/feature-return/hooks";
function useReturnableLines(orderId: string)

Returns A React Query result: data, isPending, error and the rest.

useReturnableOrdersRead a page of the shopper's delivered orders that can still be returned, for the active scope.
import { useReturnableOrders } from "@evolve-storefront/feature-return/hooks";
function useReturnableOrders(args?: { page?: number | undefined; pageSize?: number | undefined; })
OptionTypeDescription
page?number
pageSize?number

Returns A React Query result: data, isPending, error and the rest.

useReturnEstimateRead what a return of these lines would withhold, such as a restocking fee, so the form can show it before the buyer submits.
import { useReturnEstimate } from "@evolve-storefront/feature-return/hooks";
function useReturnEstimate(items: ReturnItemInput[])

Returns A React Query result: data, isPending, error and the rest.

useReturnExchangeOptionsRead what a line of the customer's order can be exchanged for: other variants of its product that are in stock and cost no more than was paid.
import { useReturnExchangeOptions } from "@evolve-storefront/feature-return/hooks";
function useReturnExchangeOptions(orderId: string, lineItemId: string, options?: { enabled?: boolean | undefined; })
OptionTypeDescription
enabled?boolean

Returns A React Query result: data, isPending, error and the rest.

useReturnReasonsRead the reasons a buyer may give, with which of them require photos.
import { useReturnReasons } from "@evolve-storefront/feature-return/hooks";
function useReturnReasons()

Returns A React Query result: data, isPending, error and the rest.

useReturnRefundMethodsHow a consumer's return of the order may be paid back, for the request form's refundMethods.
import { useReturnRefundMethods } from "@evolve-storefront/feature-return/hooks";
function useReturnRefundMethods(orderId: string)

Returns A React Query result: data, isPending, error and the rest.

useReturnsRead a page of the shopper's returns for the active scope, optionally only those in the given statuses.
import { useReturns } from "@evolve-storefront/feature-return/hooks";
function useReturns(args?: { page?: number | undefined; pageSize?: number | undefined; status?: ReturnStatus[] | undefined; })
OptionTypeDescription
page?number
pageSize?number
status?ReturnStatus[]

Returns A React Query result: data, isPending, error and the rest.

Changing data

useCancelReturnWithdraw a return that is still cancellable.
import { useCancelReturn } from "@evolve-storefront/feature-return/hooks";
function useCancelReturn()

Returns A React Query mutation: mutate, mutateAsync, isPending and the rest.

useCreateReturnRequest a return.
import { useCreateReturn } from "@evolve-storefront/feature-return/hooks";
function useCreateReturn()

Returns A React Query mutation: mutate, mutateAsync, isPending and the rest.