OrderService
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.GIFT_CARD_CREATED
stringRequiredDefault: "order.gift_card_created"
Events.PAYMENT_CAPTURED
stringRequiredDefault: "order.payment_captured"
Events.PAYMENT_CAPTURE_FAILED
stringRequiredDefault: "order.payment_capture_failed"
Events.SHIPMENT_CREATED
stringRequiredDefault: "order.shipment_created"
Events.FULFILLMENT_CREATED
stringRequiredDefault: "order.fulfillment_created"
Events.FULFILLMENT_CANCELED
stringRequiredDefault: "order.fulfillment_canceled"
Events.RETURN_REQUESTED
stringRequiredDefault: "order.return_requested"
Events.ITEMS_RETURNED
stringRequiredDefault: "order.items_returned"
Events.RETURN_ACTION_REQUIRED
stringRequiredDefault: "order.return_action_required"
Events.REFUND_CREATED
stringRequiredDefault: "order.refund_created"
Events.REFUND_FAILED
stringRequiredDefault: "order.refund_failed"
Events.SWAP_CREATED
stringRequiredDefault: "order.swap_created"
Events.PLACED
stringRequiredDefault: "order.placed"
Events.UPDATED
stringRequiredDefault: "order.updated"
Events.CANCELED
stringRequiredDefault: "order.canceled"
Events.COMPLETED
stringRequiredDefault: "order.completed"
featureFlagRouter_
FlagRouterRequiredremoteLink_
RemoteLinkRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredlist
Parameters
Returns
listAndCount
Parameters
Returns
transformQueryForTotals
Parameters
Returns
retrieve
Gets an order by id.
Parameters
orderId
stringRequiredDefault: {}
Returns
retrieveLegacy
Parameters
Default: {}
Returns
retrieveWithTotals
Parameters
orderId
stringRequiredDefault: {}
context
TotalsContextRequiredDefault: {}
Returns
retrieveByCartId
Gets an order by cart id.
Parameters
cartId
stringRequiredDefault: {}
Returns
retrieveByCartIdWithTotals
Parameters
cartId
stringRequiredDefault: {}
Returns
retrieveByExternalId
Gets an order by id.
Parameters
externalId
stringRequiredDefault: {}
Returns
completeOrder
Parameters
orderId
stringRequiredReturns
createFromCart
Creates an order from a cart
Parameters
Returns
createGiftCardsFromLineItem_
Parameters
Returns
createShipment
Adds a shipment to the order to indicate that an order has left the warehouse. Will ask the fulfillment provider for any documents that may have been created in regards to the shipment.
Parameters
orderId
stringRequiredfulfillmentId
stringRequiredconfig
objectRequiredconfig.metadata
Record<string, unknown>RequiredtrackingLinks
TrackingLink[]config.no_notification
booleanReturns
updateBillingAddress
Updates the order's billing address.
Parameters
Returns
Promise
Promise<void>RequiredupdateShippingAddress
Updates the order's shipping address.
Parameters
Returns
Promise
Promise<void>RequiredaddShippingMethod
Parameters
orderId
stringRequiredoptionId
stringRequiredconfig
CreateShippingMethodDtoRequiredDefault: {}
data
Record<string, unknown>Returns
update
Updates an order. Metadata updates should
use dedicated method, e.g. setMetadata
etc. The function
will throw errors if metadata updates are attempted.
Parameters
orderId
stringRequiredupdate
UpdateOrderInputRequiredReturns
cancel
Cancels an order. Throws if fulfillment process has been initiated. Throws if payment process has been initiated.
Parameters
orderId
stringRequiredReturns
capturePayment
Captures payment for an order.
Parameters
orderId
stringRequiredReturns
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
quantity
numberRequiredReturns
createFulfillment
Creates fulfillments for an order. In a situation where the order has more than one shipping method, we need to partition the order items, such that they can be sent to their respective fulfillment provider.
Parameters
orderId
stringRequireditemsToFulfill
FulFillmentItemType[]Requiredconfig
objectRequiredDefault: {}
config.no_notification
booleanconfig.location_id
stringconfig.metadata
Record<string, unknown>Returns
cancelFulfillment
Cancels a fulfillment (if related to an order)
Parameters
fulfillmentId
stringRequiredReturns
getFulfillmentItems
Retrieves the order line items, given an array of items.
Parameters
items
FulFillmentItemType[]RequiredReturns
archive
Archives an order. It only alloved, if the order has been fulfilled and payment has been captured.
Parameters
orderId
stringRequiredReturns
createRefund
Refunds a given amount back to the customer.
Parameters
orderId
stringRequiredrefundAmount
numberRequiredreason
stringRequiredconfig
objectRequirednote
stringconfig.no_notification
booleanReturns
decorateTotalsLegacy
Parameters
totalsFields
string[]RequiredDefault: []
Returns
decorateTotals
**decorateTotals**(order, totalsFields?): Promise<[Order](/references/entities/classes/Order)>
Calculate and attach the different total fields on the object
Parameters
totalsFields
string[]Returns
**decorateTotals**(order, context?): Promise<[Order](/references/entities/classes/Order)>
Calculate and attach the different total fields on the object
Parameters
context
TotalsContextReturns
registerReturnReceived
Handles receiving a return. 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
orderId
stringRequiredcustomRefundAmount
numberReturns
getTotalsRelations
Parameters
Returns
string[]
string[]Required