Skip to content

feature-return setup

Styles

Import them once, in the stylesheet where you load Tailwind:

@import "@evolve-storefront/feature-return/styles.css";

Translations

The package ships its texts in @evolve-storefront/feature-return/messages. evolve messages merges them into your message files and never overwrites a text you changed.

ReturnProvider

Single provider for the return feature. Supplies the injected auth/session/mode seam the data hooks read. handling: "offline" swaps the form for a notice; mode: "business" scopes reads/creates to the company and gates creation on createCapability.

import { ReturnProvider } from "@evolve-storefront/feature-return/provider";
PropTypeDescription
childrenReactNode
mode?ReturnMode
handling?ReturnHandling

"offline" shows a notice instead of the form.

isAuthenticated?boolean
businessUnitId?string
capabilities?string[]
createCapability?string

Capability required to create a return in business mode.

Prefetching on the server

Fetch the data in a Server Component so the page renders with it instead of a skeleton.

returnableLinesQueryOptionsThe lines of an order that can still be returned; null when the order is not found.
import { returnableLinesQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnableLinesQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; orderId: string; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnableLine[] | null, Error, ReturnableLine[] | null, readonly ["returns", "returnable", string, string]>, "queryFn"> & { queryFn?:…
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
orderIdstring
enabled?boolean
returnableOrdersQueryOptionsA page of the scope's delivered orders that still have lines to return.
import { returnableOrdersQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnableOrdersQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; page?: number | undefined; pageSize?: number | undefined; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnableOrderResult | null, Error, ReturnableOrderResult | null, readonly ["returns", "list", string, "returnable-orders", number, n…
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
page?number
pageSize?number
enabled?boolean
returnEstimateQueryOptionsWhat a return of these lines would withhold; disabled while nothing is chosen.
import { returnEstimateQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnEstimateQueryOptions(
args: { gqlClient: ClientFetcher; items: ReturnItemInput[]; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnEstimate | null, Error, ReturnEstimate | null, readonly ["returns", "estimate", { orderId: string; lineItemId: string; quantity:…
OptionTypeDescription
gqlClientClientFetcher
itemsReturnItemInput[]
enabled?boolean
returnExchangeOptionsQueryOptionsWhat a line of the customer's order can be exchanged for: other variants in stock that cost no more than was paid.
import { returnExchangeOptionsQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnExchangeOptionsQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; orderId: string; lineItemId: string; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnExchangeOption[], Error, ReturnExchangeOption[], readonly ["returns", "exchange-options", string, string, string]>, "queryFn"> &…
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
orderIdstring
lineItemIdstring
enabled?boolean
returnQueryOptionsA single return by id, read again before its attachment links expire.
import { returnQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; id: string; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<Return | null, Error, Return | null, readonly ["returns", "detail", string, string]>, "queryFn"> & { queryFn?: QueryFunction<Return | …
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
idstring
enabled?boolean
returnReasonsQueryOptionsThe reasons a buyer may give, in the store's locale.
import { returnReasonsQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnReasonsQueryOptions(
args: { gqlClient: ClientFetcher; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnReasonOption[], Error, ReturnReasonOption[], readonly ["returns", "reasons"]>, "queryFn"> & { queryFn?: QueryFunction<ReturnReas…
OptionTypeDescription
gqlClientClientFetcher
enabled?boolean
returnRefundMethodsQueryOptionsHow a consumer's return of this order may be paid back.
import { returnRefundMethodsQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnRefundMethodsQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; orderId: string; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnRefundMethod[], Error, ReturnRefundMethod[], readonly ["returns", "refund-methods", string, string]>, "queryFn"> & { queryFn?: Q…
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
orderIdstring
enabled?boolean
returnsQueryOptionsA page of returns for the scope, optionally only those in the given statuses.
import { returnsQueryOptions } from "@evolve-storefront/feature-return/queries";
function returnsQueryOptions(
args: { gqlClient: ClientFetcher; scope: ReturnScope; page?: number | undefined; pageSize?: number | undefined; status?: ReturnStatus[] | undefined; enabled?: boolean | undefined; },
): OmitKeyof<UseQueryOptions<ReturnResult | null, Error, ReturnResult | null, readonly ["returns", "list", string, number, number | "default", any]>, "queryFn"> & …
OptionTypeDescription
gqlClientClientFetcher
scopeReturnScope
page?number
pageSize?number
status?ReturnStatus[]
enabled?boolean