feat: emit workflow events for price lists, promotions, and campaigns…#14722
Open
p-stalega wants to merge 2 commits intomedusajs:developfrom
Open
feat: emit workflow events for price lists, promotions, and campaigns…#14722p-stalega wants to merge 2 commits intomedusajs:developfrom
p-stalega wants to merge 2 commits intomedusajs:developfrom
Conversation
🦋 Changeset detectedLatest commit: 617a00b The changes in this PR will be included in the next version bump. This PR includes changesets to release 76 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@p-stalega is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… (Omnibus)
Summary
What — What changes are introduced in this PR?
This PR adds workflow events for price lists, promotions, and campaigns so subscribers can react to these changes.
Concretely:
New event constants are added in @medusajs/utils (PriceListWorkflowEvents, PromotionWorkflowEvents, CampaignWorkflowEvents), and the existing create/update/delete/batch workflows in @medusajs/core-flows call emitEventStep so these events are emitted. No new API surface or breaking changes.
Why — Why are these changes relevant or necessary?
The EU Omnibus Directive requires showing the lowest price applied in the 30 days before a current reduction when displaying a discount. To support that, storefronts and packages need to know when prices and promotions/campaigns change. Without workflow events for these operations, there is no supported, event-driven way to maintain price history and discount applicability. These events allow subscribers (e.g. Omnibus-oriented packages) to react to changes and stay in sync with Medusa’s pricing and promotion state.
How — How have these changes been implemented?
New constants with JSDoc and @eventPayload in the same style as existing workflow events (e.g. CartWorkflowEvents, SalesChannelWorkflowEvents).
In the relevant workflows we:
Workflows touched: create/update/delete price lists, batch price list prices; create/update/delete promotions, update promotion status, batch promotion rules; create/update/delete campaigns, add-or-remove campaign promotions.
Testing — How have these changes been tested, or how can the reviewer test the feature?
Examples
Subscribing to the new events in a Medusa subscriber:
Payload shapes (as in JSDoc):
Checklist
Please ensure the following before requesting a review:
yarn changesetand follow the promptsAdditional Context
I implemented the changes in this PR as a local patch and built a separate package on top of these workflow events (Omnibus compliance). I plan to release that package to the community once this PR is merged upstream.
Note
Medium Risk
Adds new event emissions across multiple pricing/promotion workflows; risk is mainly around unintended extra event traffic or payload/ordering assumptions for subscribers, but core business logic remains largely unchanged.
Overview
Adds new workflow event constants in
packages/core/utils/src/core-flows/events.tsfor price lists, promotions, and campaigns (including batch-update style events for price list prices and promotion rules, plus campaign promotion link updates).Updates the corresponding
@medusajs/core-flowscreate/update/delete (and related) workflows to callemitEventStepwith transformed payloads (typically{ id }arrays or a batch summary object), so external subscribers can react to pricing/promotion state changes.Includes a changeset bumping
@medusajs/utilsand@medusajs/core-flowsas patch releases.Written by Cursor Bugbot for commit 617a00b. This will update automatically on new commits. Configure here.