You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Whenever a project installs a custom OrderItemPriceCalculationStrategy, it won't allow you to use a plugin that uses a custom strategy. Or vice versa, whichever is loaded last overrides the others.
In our cases, most times a custom OrderItemPriceCalculationStrategy is used, it's only used for specific products or cases. If the custom strategy is not applicable, we call super.calculateUnitPrice(ctx, productVariant). See an example in the Stripe Subscription plugin.
The problem here, is that super always refers to the built-in strategy. There is no way to reference previously loaded strategies.
Describe the solution you'd like
It would be nice if our custom strategy can say This is not for me, try next strategy in stack. I haven't looked into the details, but I imagine we can have something like this:
// In vendure-config, we change to accepting an array of strategies. Plugins would just add to this array (or prepend?)config.orderOptions.orderItemPriceCalculationStrategies=[newCustomOrderItemCalculation(),newAnotherOrderItemCalculation(),];// In our strategy, we should be able to return `false`, indicating that we weren't able to calculate the unit price.asynccalculateUnitPrice(ctx,productVariant): Promise<PriceCalculationResult|false>{if(!productVariant.customFields.useCustomPrice){// Not for this strategy. Try next in stackreturnfalse;}// Or, return custom pricereturn{priceIncludesTax: true,price: productVariant.customFields.customPrice,};}
Describe alternatives you've considered
We try to avoid OrderItemPriceCalculationStrategy where possible, because it's quite intrusive in that it won't allow you to use any plugins that also use the same strategy.
Is your feature request related to a problem? Please describe.
Whenever a project installs a custom
OrderItemPriceCalculationStrategy
, it won't allow you to use a plugin that uses a custom strategy. Or vice versa, whichever is loaded last overrides the others.In our cases, most times a custom
OrderItemPriceCalculationStrategy
is used, it's only used for specific products or cases. If the custom strategy is not applicable, we callsuper.calculateUnitPrice(ctx, productVariant)
. See an example in the Stripe Subscription plugin.The problem here, is that
super
always refers to the built-in strategy. There is no way to reference previously loaded strategies.Describe the solution you'd like
It would be nice if our custom strategy can say
This is not for me, try next strategy in stack
. I haven't looked into the details, but I imagine we can have something like this:Describe alternatives you've considered
We try to avoid OrderItemPriceCalculationStrategy where possible, because it's quite intrusive in that it won't allow you to use any plugins that also use the same strategy.
Additional context
Discord question: https://discord.com/channels/1100672177260478564/1225093130974531616
The text was updated successfully, but these errors were encountered: