From 338a42f72808052f8d4dcbda8e070b97048bac87 Mon Sep 17 00:00:00 2001 From: William Bouchard <46496014+willbouch@users.noreply.github.com> Date: Mon, 25 Aug 2025 09:35:17 -0400 Subject: [PATCH] chore(promotion): cleanup old unused promotion codebase (#13294) * chore(promotion): cleanup old unused code * changeset --- .changeset/hungry-ducks-remain.md | 5 ++++ .../src/utils/compute-actions/line-items.ts | 26 +++---------------- 2 files changed, 8 insertions(+), 23 deletions(-) create mode 100644 .changeset/hungry-ducks-remain.md diff --git a/.changeset/hungry-ducks-remain.md b/.changeset/hungry-ducks-remain.md new file mode 100644 index 0000000000..824be4abd4 --- /dev/null +++ b/.changeset/hungry-ducks-remain.md @@ -0,0 +1,5 @@ +--- +"@medusajs/promotion": patch +--- + +chore(promotion): cleanup old unused promotion codebase diff --git a/packages/modules/promotion/src/utils/compute-actions/line-items.ts b/packages/modules/promotion/src/utils/compute-actions/line-items.ts index d4d695d20f..685871de42 100644 --- a/packages/modules/promotion/src/utils/compute-actions/line-items.ts +++ b/packages/modules/promotion/src/utils/compute-actions/line-items.ts @@ -1,8 +1,4 @@ -import { - ApplicationMethodAllocationValues, - BigNumberInput, - PromotionTypes, -} from "@medusajs/framework/types" +import { ApplicationMethodAllocationValues, BigNumberInput, PromotionTypes, } from "@medusajs/framework/types" import { ApplicationMethodAllocation, ApplicationMethodTargetType, @@ -45,9 +41,7 @@ export function getComputedActionsForItems( function applyPromotionToItems( promotion: PromotionTypes.PromotionDTO, - items: - | PromotionTypes.ComputeActionContext[TargetType.ITEMS] - | PromotionTypes.ComputeActionContext[TargetType.SHIPPING_METHODS], + items: PromotionTypes.ComputeActionContext[TargetType.ITEMS], appliedPromotionsMap: Map, allocationOverride?: ApplicationMethodAllocationValues ): PromotionTypes.ComputeActions[] { @@ -72,13 +66,10 @@ function applyPromotionToItems( return computedActions } - const isTargetShippingMethod = target === TargetType.SHIPPING_METHODS const isTargetLineItems = target === TargetType.ITEMS const isTargetOrder = target === TargetType.ORDER const promotionValue = applicationMethod?.value ?? 0 - const maxQuantity = isTargetShippingMethod - ? 1 - : applicationMethod?.max_quantity! + const maxQuantity = applicationMethod?.max_quantity! let lineItemsAmount = MathBN.convert(0) if (allocation === ApplicationMethodAllocation.ACROSS) { @@ -109,10 +100,6 @@ function applyPromotionToItems( continue } - if (isTargetShippingMethod) { - item.quantity = 1 - } - const appliedPromoValue = appliedPromotionsMap.get(item.id) ?? 0 const amount = calculateAdjustmentAmountFromPromotion( @@ -152,13 +139,6 @@ function applyPromotionToItems( code: promotion.code!, is_tax_inclusive: promotion.is_tax_inclusive, }) - } else if (isTargetShippingMethod) { - computedActions.push({ - action: ComputedActions.ADD_SHIPPING_METHOD_ADJUSTMENT, - shipping_method_id: item.id, - amount, - code: promotion.code!, - }) } }