The OrderItemPriceCalculationStrategy defines the listPrice of an OrderLine when adding an item to an Order. By default the DefaultOrderItemPriceCalculationStrategy is used.
This is configured via the orderOptions.orderItemPriceCalculationStrategy property of
your VendureConfig.
Both the OrderItemPriceCalculationStrategy and Promotions can be used to alter the price paid for a product.
The main difference is when a Promotion is applied, it adds a discount line to the Order, and the regular
price is used for the value of OrderLine.listPrice property, whereas
the OrderItemPriceCalculationStrategy actually alters the value of OrderLine.listPrice itself, and does not
add any discounts to the Order.
Use OrderItemPriceCalculationStrategy if:
Use Promotions if:
A custom OrderItemPriceCalculationStrategy can be used to implement things like:
true,
a gift-wrapping surcharge would be added to the price.InjectableStrategy(ctx: RequestContext, productVariant: ProductVariant, orderLineCustomFields: { [key: string]: any }, order: Order, quantity: number) => PriceCalculationResult | Promise<PriceCalculationResult>Receives the ProductVariant to be added to the Order as well as any OrderLine custom fields and returns the price for a single unit.
Note: if you have any relation type custom fields defined on the OrderLine entity, they will only be
passed in to this method if they are set to eager: true. Otherwise, you can use the EntityHydratorto join the missing relations.
Note: the quantity argument was added in v2.0.0