From 5df903f5fb52d1e37d13bfe72ed9c226c1eb46b4 Mon Sep 17 00:00:00 2001 From: Pepijn Date: Tue, 21 Oct 2025 19:36:29 +0200 Subject: [PATCH] Added shipping method data to tax module context (#13747) --- .changeset/late-seals-mix.md | 6 +++++ .../src/tax/steps/get-item-tax-lines.ts | 6 +++++ packages/core/types/src/tax/common.ts | 25 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 .changeset/late-seals-mix.md diff --git a/.changeset/late-seals-mix.md b/.changeset/late-seals-mix.md new file mode 100644 index 0000000000..3b6cac40a9 --- /dev/null +++ b/.changeset/late-seals-mix.md @@ -0,0 +1,6 @@ +--- +"@medusajs/core-flows": patch +"@medusajs/types": patch +--- + +Added shipping method data to tax module context diff --git a/packages/core/core-flows/src/tax/steps/get-item-tax-lines.ts b/packages/core/core-flows/src/tax/steps/get-item-tax-lines.ts index 03e4a5ba43..d1c9b583b6 100644 --- a/packages/core/core-flows/src/tax/steps/get-item-tax-lines.ts +++ b/packages/core/core-flows/src/tax/steps/get-item-tax-lines.ts @@ -91,6 +91,12 @@ function normalizeTaxModuleContext( }, customer, is_return: isReturn ?? false, + shipping_methods: orderOrCart.shipping_methods?.map((method) => ({ + id: method.id, + name: method.name, + shipping_option_id: method.shipping_option_id, + amount: method.amount, + })), } } diff --git a/packages/core/types/src/tax/common.ts b/packages/core/types/src/tax/common.ts index 609109fd54..db3016269f 100644 --- a/packages/core/types/src/tax/common.ts +++ b/packages/core/types/src/tax/common.ts @@ -490,6 +490,31 @@ export interface TaxCalculationContext { * Whether the tax lines are calculated for an order return. */ is_return?: boolean + + /** + * The shipping method details. + */ + shipping_methods?: { + /** + * The associated shipping method's ID. + */ + id: string + + /** + * The name of the shipping method. + */ + name: string + + /** + * The associated shipping options's ID. + */ + shipping_option_id: string + + /** + * The amount of the shipping method. + */ + amount: number + }[] } /**