vendure icon indicating copy to clipboard operation
vendure copied to clipboard

Feat(core): variant price calculator

Open JMPJNS opened this issue 2 years ago • 2 comments

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)

JMPJNS avatar Jun 08 '22 11:06 JMPJNS

I will do some benchmarking with really large orders to see how it impacts performance

JMPJNS avatar Jun 20 '22 10:06 JMPJNS

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

JMPJNS avatar Jun 20 '22 10:06 JMPJNS