Skip to main content

OrderSellerStrategy

OrderSellerStrategy

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

info

This is configured via the orderOptions.orderSellerStrategy property of your VendureConfig.

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>;
}

setOrderLineSellerChannel

method
(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 Channel to which this OrderLine will be assigned, which will be used to set the OrderLine sellerChannel property.

splitOrder

method

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
(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 {

}

SplitOrderContents

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

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

channelId

property

state

property

lines

property

shippingLines

property