OrderSellerStrategy

OrderSellerStrategy

Package: @vendure/core File: order-seller-strategy.ts
v2.0.0

This strategy defines how an Order can be split into multiple sub-orders for the use-case of a multivendor application.

Signature

interface OrderSellerStrategy extends InjectableStrategy {
  setOrderLineSellerChannel?(
        ctx: RequestContext,
        orderLine: OrderLine,
    ): Channel | undefined | Promise<Channel | undefined>;
  splitOrder?(ctx: RequestContext, order: Order): SplitOrderContents[] | Promise<SplitOrderContents[]>;
  afterSellerOrdersCreated?(
        ctx: RequestContext,
        aggregateOrder: Order,
        sellerOrders: Order[],
    ): void | Promise<void>;
}

Extends

Members

setOrderLineSellerChannel

method
type:
(ctx: RequestContext, orderLine: OrderLine) => Channel | undefined | Promise<Channel | undefined>

This method is called whenever a new OrderLine is added to the Order via the addItemToOrder mutation or the underlying addItemToOrder() method of the OrderService.

It should return the ID of the Channel to which this OrderLine will be assigned, which will be used to set the OrderLine sellerChannel property.

splitOrder

method
type:
(ctx: RequestContext, order: Order) => SplitOrderContents[] | Promise<SplitOrderContents[]>
Upon checkout (by default, when the Order moves from “active” to “inactive” according to the OrderPlacedStrategy), this method will be called in order to split the Order into multiple Orders, one for each Seller.

afterSellerOrdersCreated

method
type:
(ctx: RequestContext, aggregateOrder: Order, sellerOrders: Order[]) => void | Promise<void>
This method is called after splitting the orders, including calculating the totals for each of the seller Orders. This method can be used to set platform fee surcharges on the seller Orders as well as perform any payment processing needed.

DefaultOrderSellerStrategy

The DefaultOrderSellerStrategy treats the Order as single-vendor.

Signature

class DefaultOrderSellerStrategy implements OrderSellerStrategy {

}

Implements

SplitOrderContents

Package: @vendure/core File: order-seller-strategy.ts
v2.0.0

The contents of the aggregate Order which make up a single seller Order.

Signature

interface SplitOrderContents {
  channelId: ID;
  state: OrderState;
  lines: OrderLine[];
  shippingLines: ShippingLine[];
}

Members

channelId

property
type:
ID

state

property
type:
OrderState

lines

property
type:
OrderLine[]

shippingLines

property
type:
ShippingLine[]