Episerver促销活动

问题描述 投票:1回答:1
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)

episerver episerver-commerce
1个回答
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));
        }
© www.soinside.com 2019 - 2024. All rights reserved.