OrderService
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>featureFlagRouter_
FlagRouterRequiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CANCELED
stringRequiredDefault: "order.canceled"
Events.COMPLETED
stringRequiredDefault: "order.completed"
Events.FULFILLMENT_CANCELED
stringRequiredDefault: "order.fulfillment_canceled"
Events.FULFILLMENT_CREATED
stringRequiredDefault: "order.fulfillment_created"
Events.GIFT_CARD_CREATED
stringRequiredDefault: "order.gift_card_created"
Events.ITEMS_RETURNED
stringRequiredDefault: "order.items_returned"
Events.PAYMENT_CAPTURED
stringRequiredDefault: "order.payment_captured"
Events.PAYMENT_CAPTURE_FAILED
stringRequiredDefault: "order.payment_capture_failed"
Events.PLACED
stringRequiredDefault: "order.placed"
Events.REFUND_CREATED
stringRequiredDefault: "order.refund_created"
Events.REFUND_FAILED
stringRequiredDefault: "order.refund_failed"
Events.RETURN_ACTION_REQUIRED
stringRequiredDefault: "order.return_action_required"
Events.RETURN_REQUESTED
stringRequiredDefault: "order.return_requested"
Events.SHIPMENT_CREATED
stringRequiredDefault: "order.shipment_created"
Events.SWAP_CREATED
stringRequiredDefault: "order.swap_created"
Events.UPDATED
stringRequiredDefault: "order.updated"
Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
addShippingMethod
Parameters
orderId
stringRequiredoptionId
stringRequireddata
Record<string, unknown>config
CreateShippingMethodDtoRequiredDefault: {}
Returns
archive
Archives an order. It only alloved, if the order has been fulfilled and payment has been captured.
Parameters
orderId
stringRequiredReturns
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
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>Requiredcancel
Cancels an order. Throws if fulfillment process has been initiated. Throws if payment process has been initiated.
Parameters
orderId
stringRequiredReturns
cancelFulfillment
Cancels a fulfillment (if related to an order)
Parameters
fulfillmentId
stringRequiredReturns
capturePayment
Captures payment for an order.
Parameters
orderId
stringRequiredReturns
completeOrder
Parameters
orderId
stringRequiredReturns
createFromCart
Creates an order from a cart
Parameters
Returns
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.location_id
stringconfig.metadata
Record<string, unknown>config.no_notification
booleanReturns
createGiftCardsFromLineItem_
Parameters
Returns
createRefund
Refunds a given amount back to the customer.
Parameters
orderId
stringRequiredrefundAmount
numberRequiredreason
stringRequirednote
stringconfig
objectRequiredconfig.no_notification
booleanReturns
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
stringRequiredtrackingLinks
TrackingLink[]config
objectRequiredconfig.metadata
Record<string, unknown>Requiredconfig.no_notification
booleanReturns
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
decorateTotalsLegacy
Parameters
totalsFields
string[]RequiredDefault: []
Returns
getFulfillmentItems
Retrieves the order line items, given an array of items.
Parameters
items
FulFillmentItemType[]RequiredReturns
getTotalsRelations
Parameters
Returns
string[]
string[]Requiredlist
Parameters
Returns
listAndCount
Parameters
Returns
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
retrieve
Gets an order by id.
Parameters
orderId
stringRequiredDefault: {}
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
retrieveLegacy
Parameters
Default: {}
Returns
retrieveWithTotals
Parameters
orderId
stringRequiredDefault: {}
context
TotalsContextRequiredDefault: {}
Returns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleantransformQueryForTotals
Parameters
Returns
object
objectupdate
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
updateBillingAddress
Updates the order's billing address.
Parameters
Returns
Promise
Promise<void>RequiredupdateShippingAddress
Updates the order's shipping address.
Parameters
Returns
Promise
Promise<void>RequiredvalidateFulfillmentLineItem
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 | LineItemwithTransaction
Parameters
transactionManager
EntityManagerReturns
OrderService
objectRequired