Promotion onDeactivate side effects get overridden by removeCouponCode
Opened this issue · 1 comments
Describe the bug
When you apply a side effect in onDeactivate
for a promotion action
, that e.g. saves a values on an orderLine
, it gets overridden and cancelled out bc the removeCouponCode
, by saving the affectedOrderLines
that were loaded before the side effects are executed in applyPriceAdjustments
, effectively uses outdated instances of the orderlines to resave
those order lines.
To Reproduce
Steps to reproduce the behavior:
- Create a customField on an orderLine
- Write a value to it in
onActivate
- Remove the value in
onDeactivate
- Query the database to see it's still there
Expected behavior
Side effects of promotions should not be removed by accident
Environment (please complete the following information):
- @vendure/core version: 3.0.x, 3.1.1
Additional context
Another issue in this context is that a PromotionItemAction runs on an OrderLine
but the side effects runs on the entire order. It should also offer additional side effects that just operate on the Item OrderLine
I have written a fix and I will submit it as soon as I've finished writing tests.