OrderCodeStrategy

OrderCodeStrategy

OrderCodeStrategy

The OrderCodeStrategy determines how Order codes are generated. A custom strategy can be defined which e.g. integrates with an existing system to generate a code:

Example

class MyOrderCodeStrategy implements OrderCodeStrategy {
  // Some imaginary service which calls out to an existing external
  // order management system.
  private mgmtService: ExternalOrderManagementService;

  init(injector: Injector) {
    this.mgmtService = injector.get(ExternalOrderManagementService);
  }

  async generate(ctx: RequestContext) {
    const result = await this.mgmtService.getAvailableOrderParams();
    return result.code;
  }
}

Signature

interface OrderCodeStrategy extends InjectableStrategy {
  generate(ctx: RequestContext): string | Promise<string>;
}

Extends

Members

generate

method
type:
(ctx: RequestContext) => string | Promise<string>
Generates the order code.

DefaultOrderCodeStrategy

The default OrderCodeStrategy generates a random string consisting of 16 uppercase letters and numbers.

Signature

class DefaultOrderCodeStrategy implements OrderCodeStrategy {
  generate(ctx: RequestContext) => string;
}

Implements

Members

generate

method
type:
(ctx: RequestContext) => string