Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promotion onDeactivate side effects get overridden by removeCouponCode #3296

Open
mschipperheyn opened this issue Dec 26, 2024 · 1 comment
Assignees
Labels
P3: minor Non-critical, no workarounds exist type: bug 🐛 Something isn't working @vendure/core

Comments

@mschipperheyn
Copy link
Collaborator

mschipperheyn commented Dec 26, 2024

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:

  1. Create a customField on an orderLine
  2. Write a value to it in onActivate
  3. Remove the value in onDeactivate
  4. 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

@mschipperheyn mschipperheyn added the type: bug 🐛 Something isn't working label Dec 26, 2024
@mschipperheyn
Copy link
Collaborator Author

I have written a fix and I will submit it as soon as I've finished writing tests.

@mschipperheyn mschipperheyn changed the title Promotion remove side effects gets overridden by removeCouponCode Promotion onDeactivate side effects gets overridden by removeCouponCode Dec 26, 2024
@mschipperheyn mschipperheyn changed the title Promotion onDeactivate side effects gets overridden by removeCouponCode Promotion onDeactivate side effects get overridden by removeCouponCode Dec 26, 2024
@michaelbromley michaelbromley added @vendure/core P3: minor Non-critical, no workarounds exist labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3: minor Non-critical, no workarounds exist type: bug 🐛 Something isn't working @vendure/core
Projects
None yet
Development

No branches or pull requests

2 participants