MultiChannelStockLocationStrategy
MultiChannelStockLocationStrategy
The MultiChannelStockLocationStrategy is an implementation of the StockLocationStrategy. which is suitable for both single- and multichannel setups. It takes into account the active channel when determining stock levels, and also ensures that allocations are made only against stock locations which are associated with the active channel.
This strategy became the default in Vendure 3.1.0. If you want to use the previous strategy which does not take channels into account, update your VendureConfig to use to DefaultStockLocationStrategy.
class MultiChannelStockLocationStrategy extends BaseStockLocationStrategy {
getAvailableStock(ctx: RequestContext, productVariantId: ID, stockLevels: StockLevel[]) => Promise<AvailableStock>;
forAllocation(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number) => Promise<LocationWithQuantity[]>;
}
- Extends:
BaseStockLocationStrategy
getAvailableStock
(ctx: RequestContext, productVariantId: ID, stockLevels: StockLevel[]) => Promise<AvailableStock>
Returns the available stock for the given ProductVariant, taking into account the active Channel.
forAllocation
(ctx: RequestContext, stockLocations: StockLocation[], orderLine: OrderLine, quantity: number) => Promise<LocationWithQuantity[]>
This method takes into account whether the stock location is applicable to the active channel.
It furthermore respects the trackInventory
and outOfStockThreshold
settings of the ProductVariant,
in order to allocate stock only from locations which are relevant to the active channel and which
have sufficient stock available.