chore(promotion): cleanup old unused promotion codebase (#13294)
* chore(promotion): cleanup old unused code * changeset
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/promotion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(promotion): cleanup old unused promotion codebase
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
import {
|
import { ApplicationMethodAllocationValues, BigNumberInput, PromotionTypes, } from "@medusajs/framework/types"
|
||||||
ApplicationMethodAllocationValues,
|
|
||||||
BigNumberInput,
|
|
||||||
PromotionTypes,
|
|
||||||
} from "@medusajs/framework/types"
|
|
||||||
import {
|
import {
|
||||||
ApplicationMethodAllocation,
|
ApplicationMethodAllocation,
|
||||||
ApplicationMethodTargetType,
|
ApplicationMethodTargetType,
|
||||||
@@ -45,9 +41,7 @@ export function getComputedActionsForItems(
|
|||||||
|
|
||||||
function applyPromotionToItems(
|
function applyPromotionToItems(
|
||||||
promotion: PromotionTypes.PromotionDTO,
|
promotion: PromotionTypes.PromotionDTO,
|
||||||
items:
|
items: PromotionTypes.ComputeActionContext[TargetType.ITEMS],
|
||||||
| PromotionTypes.ComputeActionContext[TargetType.ITEMS]
|
|
||||||
| PromotionTypes.ComputeActionContext[TargetType.SHIPPING_METHODS],
|
|
||||||
appliedPromotionsMap: Map<string, BigNumberInput>,
|
appliedPromotionsMap: Map<string, BigNumberInput>,
|
||||||
allocationOverride?: ApplicationMethodAllocationValues
|
allocationOverride?: ApplicationMethodAllocationValues
|
||||||
): PromotionTypes.ComputeActions[] {
|
): PromotionTypes.ComputeActions[] {
|
||||||
@@ -72,13 +66,10 @@ function applyPromotionToItems(
|
|||||||
return computedActions
|
return computedActions
|
||||||
}
|
}
|
||||||
|
|
||||||
const isTargetShippingMethod = target === TargetType.SHIPPING_METHODS
|
|
||||||
const isTargetLineItems = target === TargetType.ITEMS
|
const isTargetLineItems = target === TargetType.ITEMS
|
||||||
const isTargetOrder = target === TargetType.ORDER
|
const isTargetOrder = target === TargetType.ORDER
|
||||||
const promotionValue = applicationMethod?.value ?? 0
|
const promotionValue = applicationMethod?.value ?? 0
|
||||||
const maxQuantity = isTargetShippingMethod
|
const maxQuantity = applicationMethod?.max_quantity!
|
||||||
? 1
|
|
||||||
: applicationMethod?.max_quantity!
|
|
||||||
|
|
||||||
let lineItemsAmount = MathBN.convert(0)
|
let lineItemsAmount = MathBN.convert(0)
|
||||||
if (allocation === ApplicationMethodAllocation.ACROSS) {
|
if (allocation === ApplicationMethodAllocation.ACROSS) {
|
||||||
@@ -109,10 +100,6 @@ function applyPromotionToItems(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTargetShippingMethod) {
|
|
||||||
item.quantity = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
const appliedPromoValue = appliedPromotionsMap.get(item.id) ?? 0
|
const appliedPromoValue = appliedPromotionsMap.get(item.id) ?? 0
|
||||||
|
|
||||||
const amount = calculateAdjustmentAmountFromPromotion(
|
const amount = calculateAdjustmentAmountFromPromotion(
|
||||||
@@ -152,13 +139,6 @@ function applyPromotionToItems(
|
|||||||
code: promotion.code!,
|
code: promotion.code!,
|
||||||
is_tax_inclusive: promotion.is_tax_inclusive,
|
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