OrderSellerStrategy
OrderSellerStrategy
This strategy defines how an Order can be split into multiple sub-orders for the use-case of a multivendor application.
This is configured via the orderOptions.orderSellerStrategy
property of
your VendureConfig.
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:
InjectableStrategy
setOrderLineSellerChannel
(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
(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
(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.
class DefaultOrderSellerStrategy implements OrderSellerStrategy {
}
- Implements:
OrderSellerStrategy
SplitOrderContents
The contents of the aggregate Order which make up a single seller Order.
interface SplitOrderContents {
channelId: ID;
state: OrderState;
lines: OrderLine[];
shippingLines: ShippingLine[];
}