Skip to content

Commit 338a42f

Browse files
authored
chore(promotion): cleanup old unused promotion codebase (medusajs#13294)
* chore(promotion): cleanup old unused code * changeset
1 parent fc49253 commit 338a42f

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

.changeset/hungry-ducks-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/promotion": patch
3+
---
4+
5+
chore(promotion): cleanup old unused promotion codebase

packages/modules/promotion/src/utils/compute-actions/line-items.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
ApplicationMethodAllocationValues,
3-
BigNumberInput,
4-
PromotionTypes,
5-
} from "@medusajs/framework/types"
1+
import { ApplicationMethodAllocationValues, BigNumberInput, PromotionTypes, } from "@medusajs/framework/types"
62
import {
73
ApplicationMethodAllocation,
84
ApplicationMethodTargetType,
@@ -45,9 +41,7 @@ export function getComputedActionsForItems(
4541

4642
function applyPromotionToItems(
4743
promotion: PromotionTypes.PromotionDTO,
48-
items:
49-
| PromotionTypes.ComputeActionContext[TargetType.ITEMS]
50-
| PromotionTypes.ComputeActionContext[TargetType.SHIPPING_METHODS],
44+
items: PromotionTypes.ComputeActionContext[TargetType.ITEMS],
5145
appliedPromotionsMap: Map<string, BigNumberInput>,
5246
allocationOverride?: ApplicationMethodAllocationValues
5347
): PromotionTypes.ComputeActions[] {
@@ -72,13 +66,10 @@ function applyPromotionToItems(
7266
return computedActions
7367
}
7468

75-
const isTargetShippingMethod = target === TargetType.SHIPPING_METHODS
7669
const isTargetLineItems = target === TargetType.ITEMS
7770
const isTargetOrder = target === TargetType.ORDER
7871
const promotionValue = applicationMethod?.value ?? 0
79-
const maxQuantity = isTargetShippingMethod
80-
? 1
81-
: applicationMethod?.max_quantity!
72+
const maxQuantity = applicationMethod?.max_quantity!
8273

8374
let lineItemsAmount = MathBN.convert(0)
8475
if (allocation === ApplicationMethodAllocation.ACROSS) {
@@ -109,10 +100,6 @@ function applyPromotionToItems(
109100
continue
110101
}
111102

112-
if (isTargetShippingMethod) {
113-
item.quantity = 1
114-
}
115-
116103
const appliedPromoValue = appliedPromotionsMap.get(item.id) ?? 0
117104

118105
const amount = calculateAdjustmentAmountFromPromotion(
@@ -152,13 +139,6 @@ function applyPromotionToItems(
152139
code: promotion.code!,
153140
is_tax_inclusive: promotion.is_tax_inclusive,
154141
})
155-
} else if (isTargetShippingMethod) {
156-
computedActions.push({
157-
action: ComputedActions.ADD_SHIPPING_METHOD_ADJUSTMENT,
158-
shipping_method_id: item.id,
159-
amount,
160-
code: promotion.code!,
161-
})
162142
}
163143
}
164144

0 commit comments

Comments
 (0)