FulfillmentService
admin/discounts.internal.FulfillmentService
Handles Fulfillments
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
cancelFulfillment
cancelFulfillment(fulfillmentOrId
): Promise
<Fulfillment
>
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
Returns
Promise
<Fulfillment
>
the result of the save operation
createFulfillment
createFulfillment(order
, itemsToFulfill
, custom?
): Promise
<Fulfillment
[]>
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
custom
Partial<Fulfillment>Returns
Promise
<Fulfillment
[]>
the created fulfillments
createShipment
createShipment(fulfillmentId
, trackingLinks?
, config?
): Promise
<Fulfillment
>
Creates a shipment by marking a fulfillment as shipped. Adds tracking links and potentially more metadata.
Parameters
fulfillmentId
stringRequiredtrackingLinks
{ tracking_number: string }[]config
CreateShipmentConfigReturns
Promise
<Fulfillment
>
the shipped fulfillment
getFulfillmentItems_
getFulfillmentItems_(order
, items
): Promise
<(null
| LineItem
)[]>
Retrieves the order line items, given an array of items.
Parameters
Returns
Promise
<(null
| LineItem
)[]>
the line items generated by the transformer.
partitionItems_
partitionItems_(shippingMethods
, items
): FulfillmentItemPartition
[]
Parameters
Returns
retrieve
retrieve(fulfillmentId
, config?
): Promise
<Fulfillment
>
Retrieves a fulfillment by its id.
Parameters
fulfillmentId
stringRequiredconfig
FindConfig<Fulfillment>Returns
Promise
<Fulfillment
>
the fulfillment
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
validateFulfillmentLineItem_
validateFulfillmentLineItem_(item
, quantity
): null
| LineItem
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
quantity
numberRequiredReturns
null
| LineItem
``null`` \| LineItem
null | LineItemwithTransaction
withTransaction(transactionManager?
): FulfillmentService
Parameters
transactionManager
EntityManager