vendure
vendure copied to clipboard
Feat(core): variant price calculator
Description
This PR adds a new helper service that can calculate the price of a variant, including promotions, without having to manually create the order, orderLines, orderItems... every time.
You can either supply a base order where it adds the variant and executes the promotions on, or use the currently active order for the session customer (default)
There are still some open fixme and todos that need to be adressed, i was hoping that @michaelbromley can give some input on those (what errors should be used and if it should just return the regular price in case it can't be calculated)
I will do some benchmarking with really large orders to see how it impacts performance
and yes all of this can live inside a plugin, currently we have a custom query to get discounted prices for variants, it is used to show discounted prices right in the product display grid, since without this calculation the discounts are only shown after adding an item to your cart/order