Skip to main content
Skip to main content

ReturnService

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
featureFlagRouter_FlagRouterRequired
fulfillmentProviderService_FulfillmentProviderServiceRequired
lineItemService_LineItemServiceRequired
manager_EntityManagerRequired
orderService_OrderServiceRequired
productVariantInventoryService_ProductVariantInventoryServiceRequired
returnItemRepository_Repository<ReturnItem>Required
returnReasonService_ReturnReasonServiceRequired
returnRepository_Repository<Return>Required
shippingOptionService_ShippingOptionServiceRequired
taxProviderService_TaxProviderServiceRequired
totalsService_TotalsServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Inherited from

TransactionBaseService.activeManager_

Methods

atomicPhase_

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Parameters
work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler
Returns
PromisePromise<TResult>Required
the result of the transactional work

cancel

Cancels a return if possible. Returns can be canceled if it has not been received.

Parameters
returnIdstringRequired
the id of the return to cancel.
Returns
PromisePromise<Return>Required
the updated Return

create

Creates a return request for an order, with given items, and a shipping method. If no refund amount is provided the refund amount is calculated from the return lines and the shipping cost.

Parameters
dataCreateReturnInputRequired
data to use for the return e.g. shipping_method, items or refund_amount
Returns
PromisePromise<Return>Required
the created return

fulfill

Parameters
returnIdstringRequired
Returns
PromisePromise<Return>Required

getFulfillmentItems

Retrieves the order line items, given an array of items

Parameters
orderOrderRequired
the order to get line items from
itemsOrdersReturnItem[]Required
the items to get
transformerTransformerRequired
a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array.
Returns
PromisePromise<LineItem & { note?: string ; reason_id?: string }[]>Required
the line items generated by the transformer.

list

Parameters
selectorSelector<Return>Required
the query object for find
the config object for find
Returns
PromisePromise<Return[]>Required
the result of the find operation

listAndCount

Parameters
selectorSelector<Return>Required
the query object for find
the config object for find
Returns
PromisePromise<[Return[], number]>Required
the result of the find operation

receive

Registers a previously requested return as received. This will create a refund to the customer. If the returned items don't match the requested items the return status will be updated to requires_action. This behaviour is useful in situations where a custom refund amount is requested, but the returned items are not matching the requested items. Setting the allowMismatch argument to true, will process the return, ignoring any mismatches.

Parameters
returnIdstringRequired
the orderId to return to
receivedItemsOrdersReturnItem[]Required
the items received after return.
refundAmountnumber
the amount to return
allowMismatchboolean
whether to ignore return/received product mismatch
contextobject
context.locationIdstring
Returns
PromisePromise<Return>Required
the result of the update operation

retrieve

Retrieves a return by its id.

Parameters
returnIdstringRequired
the id of the return to retrieve
the config object
Returns
PromisePromise<Return>Required
the return

retrieveBySwap

Parameters
swapIdstringRequired
relationsstring[]
Returns
PromisePromise<Return>Required

shouldRetryTransaction_

Parameters
errRecord<string, unknown> | { code: string }Required
Returns
booleanboolean

update

Parameters
returnIdstringRequired
updateUpdateReturnInputRequired
Returns
PromisePromise<Return>Required

validateReturnLineItem

Checks that a given quantity of a line item can be returned. Fails if the item is undefined or if the returnable quantity of the item is lower, than the quantity that is requested to be returned.

Parameters
the line item to check has sufficient returnable quantity.
quantitynumber
the quantity that is requested to be returned.
additionalobject
the quantity that is requested to be returned.
additional.notestring
additional.reason_idstring
Returns
DeepPartialDeepPartial<LineItem>Required
a line item where the quantity is set to the requested return quantity.

validateReturnStatuses

Checks that an order has the statuses necessary to complete a return. fulfillment_status cannot be not_fulfilled or returned. payment_status must be captured.

Parameters
orderOrderRequired
the order to check statuses on
Returns
voidvoid

Throws

when statuses are not sufficient for returns.


withTransaction

Parameters
transactionManagerEntityManager
Returns
ReturnServiceReturnServiceRequired
Was this section helpful?