🚨 Announcement: A New Chapter for Vendure read more

ActiveOrderService

ActiveOrderService

This helper class is used to get a reference to the active Order from the current RequestContext.

Signature

class ActiveOrderService {
  constructor(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection, configService: ConfigService)
  async getOrderFromContext(ctx: RequestContext) => Promise<Order | undefined>;
  async getOrderFromContext(ctx: RequestContext, createIfNotExists: true) => Promise<Order>;
  async getOrderFromContext(ctx: RequestContext, createIfNotExists:  = false) => Promise<Order | undefined>;
  async getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: any } | undefined) => Promise<Order | undefined>;
  async getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: any } | undefined, createIfNotExists: true) => Promise<Order>;
  async getActiveOrder(ctx: RequestContext, input: { [strategyName: string]: Record<string, any> | undefined } | undefined, createIfNotExists:  = false) => Promise<Order | undefined>;
}

Members

constructor

method
type:
(sessionService: SessionService, orderService: OrderService, connection: TransactionalConnection, configService: ConfigService) => ActiveOrderService

getOrderFromContext

async method
type:
(ctx: RequestContext) => Promise<Order | undefined>

Gets the active Order object from the current Session. Optionally can create a new Order if no active Order exists.

Intended to be used at the Resolver layer for those resolvers that depend upon an active Order being present.

getOrderFromContext

async method
type:
(ctx: RequestContext, createIfNotExists: true) => Promise<Order>

getOrderFromContext

async method
type:
(ctx: RequestContext, createIfNotExists: = false) => Promise<Order | undefined>

getActiveOrder

async method
v1.9.0
type:
(ctx: RequestContext, input: { [strategyName: string]: any } | undefined) => Promise<Order | undefined>
Retrieves the active Order based on the configured ActiveOrderStrategy.

getActiveOrder

async method
type:
(ctx: RequestContext, input: { [strategyName: string]: any } | undefined, createIfNotExists: true) => Promise<Order>

getActiveOrder

async method
type:
(ctx: RequestContext, input: { [strategyName: string]: Record<string, any> | undefined } | undefined, createIfNotExists: = false) => Promise<Order | undefined>