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));
}
我们已定制促销,仅对需要数量的订单项应用促销。现在,当我们从其他促销中排除促销时,并且两个促销项都适用于这两个促销时,则只有一项促销同时被应用。
例如:我们希望应用一个订单项“购买10个项目并获得10%”,而其他订单项应用“购买20个项目并获得20%的出价”。
如果它是适用于促销的单个订单项,则效果很好! (我们正在使用Commerce 12.5.1)
答案 0 :(得分:0)
感谢您的答复。
我们通过使用受影响的条目来实现了解决方案。
////To check applied discount entries.
var isPromotionApplied = context.EntryPrices.Prices.Count() > 0 ? true : false;
if (isPromotionApplied)
{
////To filter the item if it have already discount.
var codesAlreadyDiscounted = context.EntryPrices.Prices.Select(x => x.ParentItem.Code);
lineItems = lineItems.Where(x => !codesAlreadyDiscounted.Contains(x.Code));
}