From d8a908bd8ee83cd5ca61b1a8078603eacbab65a9 Mon Sep 17 00:00:00 2001 From: Simons Date: Sat, 12 Aug 2023 12:44:35 +0200 Subject: [PATCH] fix(medusa): removal of shipping methods on addOrUpdateLineItems (#4725) * added removal of shipping methods on addOrUpdateLineItems * Create lovely-beds-design.md --------- Co-authored-by: Thijs Simons Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --- .changeset/lovely-beds-design.md | 5 +++++ packages/medusa/src/services/cart.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/lovely-beds-design.md diff --git a/.changeset/lovely-beds-design.md b/.changeset/lovely-beds-design.md new file mode 100644 index 0000000000..2d978a145e --- /dev/null +++ b/.changeset/lovely-beds-design.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +fix(medusa): removal of shipping methods on addOrUpdateLineItems diff --git a/packages/medusa/src/services/cart.ts b/packages/medusa/src/services/cart.ts index 90e798b55b..0110393e3d 100644 --- a/packages/medusa/src/services/cart.ts +++ b/packages/medusa/src/services/cart.ts @@ -765,7 +765,10 @@ class CartService extends TransactionBaseService { return await this.atomicPhase_( async (transactionManager: EntityManager) => { - let cart = await this.retrieve(cartId, { select }) + let cart = await this.retrieve(cartId, { + select, + relations: ["shipping_methods"] + }) if (this.featureFlagRouter_.isFeatureEnabled("sales_channels")) { if (config.validateSalesChannels) { @@ -900,6 +903,12 @@ class CartService extends TransactionBaseService { throw err }) + if (cart.shipping_methods?.length) { + await this.shippingOptionService_ + .withTransaction(transactionManager) + .deleteShippingMethods(cart.shipping_methods) + } + cart = await this.retrieve(cart.id, { relations: [ "items.variant.product.profiles",