Skip to main content

ChangedPriceHandlingStrategy

ChangedPriceHandlingStrategy

This strategy defines how we handle the situation where an item exists in an Order, and then later on another is added but in the meantime the price of the ProductVariant has changed.

By default, the latest price will be used. Any price changes resulting from using a newer price will be reflected in the GraphQL OrderLine.unitPrice[WithTax]ChangeSinceAdded field.

info

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

Signature
interface ChangedPriceHandlingStrategy extends InjectableStrategy {
handlePriceChange(
ctx: RequestContext,
current: PriceCalculationResult,
orderLine: OrderLine,
order: Order,
): PriceCalculationResult | Promise<PriceCalculationResult>;
}

handlePriceChange

This method is called when adding to or adjusting OrderLines, if the latest price (as determined by the ProductVariant price, potentially modified by the configured OrderItemPriceCalculationStrategy) differs from the initial price at the time that the OrderLine was created.