首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Episerver促销

Episerver促销
EN

Stack Overflow用户
提问于 2019-02-28 20:48:08
回答 1查看 179关注 0票数 1
代码语言:javascript
复制
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)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-03 20:48:12

谢谢你的回复。

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

代码语言:javascript
复制
  ////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));
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54926141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档