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));
}
Мы настроили акцию, чтобы применить акцию только для lineitem, который имеет необходимое количество.Теперь, когда мы исключаем рекламную акцию из других и двух позиций, применимых к обеим рекламным акциям, только одна акция применяется к обеим.
Например: мы хотим, чтобы была применена одна позиция ", купите 10 единиц и получите 10% "и другие, чтобы" купить 20 предметов и получить предложение 20% ".
Если это отдельная позиция, применимая для продвижения, она работает отлично !.(Мы используем Commerce 12.5.1)