Episerver促销活动

Episerver promotions

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));
}

我们定制了促销,仅对具有所需数量的订单项应用促销。现在,当我们从其他项目中排除一个促销活动和适用于这两个促销活动的两个订单项时,只有一个促销活动适用于这两个促销活动。

例如:我们希望应用一个订单项 "buy 10 items and get 10%" 并将其他订单项应用到 "buy 20 items and get a 20% offer"。

如果它是适用于促销的单行项目,则可以正常工作!。 (我们正在使用 Commerce 12.5.1)

感谢回复。

我们通过使用受影响的条目实现了解决方案。

  ////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));
        }