Skip to content

chore(medusa,pricing): add support for sales_channel_id as a pricing preference context for determining tax inclusivity.#15006

Open
pepijn-vanvlaanderen wants to merge 3 commits intomedusajs:developfrom
webbersagency:feat/add-sales-channel-price-preference
Open

chore(medusa,pricing): add support for sales_channel_id as a pricing preference context for determining tax inclusivity.#15006
pepijn-vanvlaanderen wants to merge 3 commits intomedusajs:developfrom
webbersagency:feat/add-sales-channel-price-preference

Conversation

@pepijn-vanvlaanderen
Copy link
Copy Markdown
Contributor

Summary

What — What changes are introduced in this PR?

Adds support for sales_channel_id as a pricing preference context for determining tax inclusivity.

Why — Why are these changes relevant or necessary?

Previously, the tax inclusivity of a price could only be determined by region_id or currency_code. Sales channels may have different tax-inclusive pricing requirements, i.e. a B2B sales channel, and there was no way to express this preference.

How — How have these changes been implemented?

Three changes in pricing-module.ts:

  1. sales_channel_id is now included in the preference context filter alongside region_id and currency_code.
  2. The isTaxInclusive helper now receives the full pricingContext instead of just region_id, allowing it to extract additional context keys.
  3. A salesChannelPreference lookup is added, and if matched, it takes precedence over region/currency preferences.

Testing — How have these changes been tested, or how can the reviewer test the feature?

Patched in (production) projects and validated accuracy.


Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.
This helps with documentation and ensures maintainers can quickly understand and verify the change.

  // Create a tax-inclusive price preference for a sales channel                                                                                                                                      
  await pricingModule.createPricePreferences([
    {                                                                                                                                                                                                 
      attribute: "sales_channel_id",
      value: "sc_123",                                                                                                                                                                                
      is_tax_inclusive: false,
    },                                                                                                                                                                                                
  ])

Checklist

Please ensure the following before requesting a review:

  • I have added a changeset for this PR
    • Every non-breaking change should be marked as a patch
    • To add a changeset, run yarn changeset and follow the prompts
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

@pepijn-vanvlaanderen pepijn-vanvlaanderen requested a review from a team as a code owner April 3, 2026 13:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: eb060f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 77 packages
Name Type
@medusajs/pricing Patch
@medusajs/medusa Patch
integration-tests-http Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/core-flows Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

@pepijn-vanvlaanderen is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

@pepijn-vanvlaanderen pepijn-vanvlaanderen changed the title Adds support for sales_channel_id as a pricing preference context for determining tax inclusivity. chore(medusa,pricing): add support for sales_channel_id as a pricing preference context for determining tax inclusivity. Apr 3, 2026
@medusa-os-bot
Copy link
Copy Markdown

medusa-os-bot bot commented Apr 9, 2026

Thank you for your contribution!

After reviewing this PR, we need a few things addressed before we can move forward:

Required changes:

  • Add tests for the new sales_channel_id tax inclusivity behavior. The PR checklist marks tests as included, but no test files are changed. A new test case should be added to the "Tax inclusivity" describe block in packages/modules/pricing/integration-tests/__tests__/services/pricing-module/calculate-price.spec.ts — following the same pattern as the existing currency_code and region_id tests. At minimum, cover: (1) a sales_channel_id preference overriding a currency_code preference, and (2) a sales_channel_id preference overriding a region_id preference.
  • Update the stale comment on line 464 of pricing-module.ts. The comment currently reads: "they use either the region or currency" — it should be updated to reflect that sales_channel_id is now also supported.
  • Link a related issue. Feature additions from community contributors should reference a pre-approved issue (see CONTRIBUTING.md). Please open or link an existing issue describing the use case, then reference it with a closing keyword in the PR body (e.g. Closes #XXXX).

Notes:

The isTaxInclusive function has an asymmetry worth being aware of: the regionPreference only applies when the price also has a regionRule (i.e. the price is explicitly region-scoped), while currencyPreference and — based on this PR's approach — salesChannelPreference apply to any price regardless of whether it has a matching rule. This means a sales_channel_id preference would affect the tax inclusivity of the default (non-channel-specific) price too. If this is intentional, a brief comment explaining the reasoning would help future maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant