protected override RewardDescription Evaluate(EntryPromotion promotionData, PromotionProcessorContext context)
{
var lineItems = GetLineItems(context.OrderForm);
var condition = promotionData.Condition;
var applicableCodes = targetEvaluator.GetApplicableCodes(lineItems, condition.Targets, condition.MatchRecursive);
var filteredLineItems = GetFilteredLineItems(lineItems, condition.RequiredQuantity);
var filteredApplicableCodes = GetFilteredApplicableCodes(applicableCodes, filteredLineItems);
if (applicableCodes.NotNullOrEmpty() && filteredApplicableCodes.IsNullOrEmpty())
{
return RewardDescription.CreatePercentageReward(
FulfillmentStatus.PartiallyFulfilled,
Enumerable.Empty<RedemptionDescription>(),
promotionData,
promotionData.Percentage,
Enum.GetName(typeof(RequestFulfillmentStatus), RequestFulfillmentStatus.PartiallyFulfilled));
}
var fulfillmentStatus = fulfillmentEvaluator.GetStatusForBuyQuantityPromotion(
filteredApplicableCodes,
filteredLineItems,
condition.RequiredQuantity,
condition.RequiredQuantity);
return RewardDescription.CreatePercentageReward(
fulfillmentStatus,
GetRedemptions(filteredApplicableCodes, promotionData, context, lineItems),
promotionData,
promotionData.Percentage,
fulfillmentStatus.GetRewardDescriptionText(localizationService));
}
We have customized promotion to apply promotion only for lineitem that has required quantity. Now, when we exclude a promotion from other and two line items applicable for both promotions, only one promotion is getting applied for both.
eg: we want one line item to get applied "buy 10 items and get 10%" and others to "buy 20 items and get a 20% offer".
If it is a single line item applicable for promotion, it works fine!. (We are using Commerce 12.5.1)