From 8c08d003198b94c00f8428a51c0e79d2ca9d1dc7 Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Mon, 16 Jan 2023 09:57:01 +0100 Subject: [PATCH] fix(medusa): Legacy total service to accept custom items (#3027) --- .changeset/early-cherries-care.md | 5 +++++ packages/medusa/src/services/totals.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/early-cherries-care.md diff --git a/.changeset/early-cherries-care.md b/.changeset/early-cherries-care.md new file mode 100644 index 0000000000..780e3659f6 --- /dev/null +++ b/.changeset/early-cherries-care.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): Legacy total service should accept custom items diff --git a/packages/medusa/src/services/totals.ts b/packages/medusa/src/services/totals.ts index 79ba4766f3..893c3dd508 100644 --- a/packages/medusa/src/services/totals.ts +++ b/packages/medusa/src/services/totals.ts @@ -840,7 +840,7 @@ class TotalsService extends TransactionBaseService { * items we have to get the line items from the tax provider. */ if (options.use_tax_lines || isOrder(cartOrOrder)) { - if (typeof lineItem.tax_lines === "undefined") { + if (!isDefined(lineItem.tax_lines) && lineItem.variant_id) { throw new MedusaError( MedusaError.Types.UNEXPECTED_STATE, "Tax Lines must be joined on items to calculate taxes" @@ -850,7 +850,7 @@ class TotalsService extends TransactionBaseService { taxLines = lineItem.tax_lines } else { if (lineItem.is_return) { - if (typeof lineItem.tax_lines === "undefined") { + if (!isDefined(lineItem.tax_lines) && lineItem.variant_id) { throw new MedusaError( MedusaError.Types.UNEXPECTED_STATE, "Return Line Items must join tax lines"