Order

Order

Order

An Order is created whenever a Customer adds an item to the cart. It contains all the information required to fulfill an order: which ProductVariants in what quantities; the shipping address and price; any applicable promotions; payments etc.

An Order exists in a well-defined state according to the OrderState type. A state machine is used to govern the transition from one state to another.

Signature

class Order extends VendureEntity implements HasCustomFields {
  constructor(input?: DeepPartial<Order>)
  @Column() code: string;
  @Column('varchar') state: OrderState;
  @Column({ default: true })
    active: boolean;
  @Column({ nullable: true })
    orderPlacedAt?: Date;
  @ManyToOne(type => Customer)
    customer?: Customer;
  @OneToMany(type => OrderLine, line => line.order)
    lines: OrderLine[];
  @Column('simple-array')
    couponCodes: string[];
  @ManyToMany(type => Promotion)
    @JoinTable()
    promotions: Promotion[];
  @Column('simple-json') pendingAdjustments: Adjustment[];
  @Column('simple-json') shippingAddress: OrderAddress;
  @Column('simple-json') billingAddress: OrderAddress;
  @OneToMany(type => Payment, payment => payment.order)
    payments: Payment[];
  @Column('varchar')
    currencyCode: CurrencyCode;
  @Column() subTotalBeforeTax: number;
  @Column() subTotal: number;
  @EntityId({ nullable: true })
    shippingMethodId: ID | null;
  @ManyToOne(type => ShippingMethod)
    shippingMethod: ShippingMethod | null;
  @Column({ default: 0 })
    shipping: number;
  @Column({ default: 0 })
    shippingWithTax: number;
  @Column(type => CustomOrderFields)
    customFields: CustomOrderFields;
  totalBeforeTax: number
  total: number
  adjustments: Adjustment[]
  promotionAdjustmentsTotal: number
  clearAdjustments(type?: AdjustmentType) => ;
  getOrderItems() => OrderItem[];
}

Members

constructor

method
type:
(input?: DeepPartial<Order>) => Order

code

property
type:
string

state

property
type:
OrderState

active

property
type:
boolean

orderPlacedAt

property
type:
Date

customer

property
type:
Customer

lines

property
type:
OrderLine[]

couponCodes

property
type:
string[]

promotions

property
type:
Promotion[]

pendingAdjustments

property
type:
Adjustment[]

shippingAddress

property
type:
OrderAddress

billingAddress

property
type:
OrderAddress

payments

property
type:
Payment[]

currencyCode

property
type:
CurrencyCode

subTotalBeforeTax

property
type:
number

subTotal

property
type:
number
The subTotal is the total of the OrderLines, before order-level promotions and shipping has been applied.

shippingMethodId

property
type:
ID | null

shippingMethod

property
type:
ShippingMethod | null

shipping

property
type:
number

shippingWithTax

property
type:
number

customFields

property
type:
CustomOrderFields

totalBeforeTax

property
type:
number

total

property
type:
number

adjustments

property
type:
Adjustment[]

promotionAdjustmentsTotal

property
type:
number

clearAdjustments

method
type:
(type?: AdjustmentType) =>

getOrderItems

method
type:
() => OrderItem[]