Акции Episerver - PullRequest
       12

Акции Episerver

0 голосов
/ 28 февраля 2019
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)

1 Ответ

0 голосов
/ 03 апреля 2019

Спасибо за ответ.

Мы достигли решения с помощью задействованных записей.

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