chore(promotion): cleanup old unused promotion codebase (#13294)
* chore(promotion): cleanup old unused code * changeset
This commit is contained in:
@@ -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<string, BigNumberInput>,
|
||||
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!,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user