Skip to main content
Skip to main content

FulfillmentService

Handles Fulfillments

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
totalsService_TotalsServiceRequired
lineItemService_LineItemServiceRequired
shippingProfileService_ShippingProfileServiceRequired
fulfillmentProviderService_FulfillmentProviderServiceRequired
fulfillmentRepository_Repository<Fulfillment>Required
trackingLinkRepository_Repository<TrackingLink>Required
lineItemRepository_Repository<LineItem> & objectRequired
productVariantInventoryService_ProductVariantInventoryServiceRequired
__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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.

Type Parameters

TResultobjectRequired
TErrorobjectRequired

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

partitionItems_

Parameters

shippingMethodsShippingMethod[]Required
itemsLineItem[]Required

Returns

FulfillmentItemPartition[]FulfillmentItemPartition[]Required

getFulfillmentItems_

Retrieves the order line items, given an array of items.

Parameters

orderCreateFulfillmentOrderRequired
the order to get line items from
itemsFulFillmentItemType[]Required
the items to get

Returns

PromisePromise<(null | LineItem)[]>Required
the line items generated by the transformer.

validateFulfillmentLineItem_

Checks that a given quantity of a line item can be fulfilled. Fails if the fulfillable quantity is lower than the requested fulfillment quantity. Fulfillable quantity is calculated by subtracting the already fulfilled quantity from the quantity that was originally purchased.

Parameters

itemundefined | LineItemRequired
the line item to check has sufficient fulfillable quantity.
quantitynumberRequired
the quantity that is requested to be fulfilled.

Returns

null | LineItemnull | LineItemRequired
a line item that has the requested fulfillment quantity set.

retrieve

Retrieves a fulfillment by its id.

Parameters

fulfillmentIdstringRequired
the id of the fulfillment to retrieve
configFindConfig<Fulfillment>Required
optional values to include with fulfillmentRepository query

Default: {}

Returns

PromisePromise<Fulfillment>Required
the fulfillment

createFulfillment

Creates an order fulfillment If items needs to be fulfilled by different provider, we make sure to partition those items, and create fulfillment for those partitions.

Parameters

orderCreateFulfillmentOrderRequired
order to create fulfillment for
itemsToFulfillFulFillmentItemType[]Required
the items in the order to fulfill
customPartial<Fulfillment>Required
potential custom values to add

Default: {}

Returns

PromisePromise<Fulfillment[]>Required
the created fulfillments

cancelFulfillment

Cancels a fulfillment with the fulfillment provider. Will decrement the fulfillment_quantity on the line items associated with the fulfillment. Throws if the fulfillment has already been shipped.

Parameters

fulfillmentOrIdstring | FulfillmentRequired
the fulfillment object or id.

Returns

PromisePromise<Fulfillment>Required
the result of the save operation

createShipment

Creates a shipment by marking a fulfillment as shipped. Adds tracking links and potentially more metadata.

Parameters

fulfillmentIdstringRequired
the fulfillment to ship
configCreateShipmentConfigRequired
potential configuration settings, such as no_notification and metadata
trackingLinksobject[]
tracking links for the shipment

Returns

PromisePromise<Fulfillment>Required
the shipped fulfillment
Was this section helpful?