Class PromotionApplicator

Evaluates promotions, and applies the reward.

Inheritance
System.Object
PromotionApplicator
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Marketing
Assembly: EPiServer.Business.Commerce.dll
Version: 10.8.0
Syntax
public class PromotionApplicator

Constructors

PromotionApplicator(PromotionProcessorResolver, RewardApplicatorResolver, IAdditionalPromotionInformationCreator)

Creates an instance of PromotionApplicator.

Declaration
public PromotionApplicator(PromotionProcessorResolver promotionProcessorResolver, RewardApplicatorResolver rewardApplicatorResolver, IAdditionalPromotionInformationCreator additionalPromotionInformationCreator)
Parameters
Type Name Description
PromotionProcessorResolver promotionProcessorResolver

The resolver used to find the correct processor for a promotion.

RewardApplicatorResolver rewardApplicatorResolver

The reward applicator resolver.

IAdditionalPromotionInformationCreator additionalPromotionInformationCreator

Adds additional custom details to fulfilled PromotionInformations.

Methods

AddPromotionInformation(IOrderForm, IOrderGroup, RewardDescription, PromotionFilterContext)

Creates promotion information instances from the reward, and adds it on the orderForm.

Declaration
public void AddPromotionInformation(IOrderForm orderForm, IOrderGroup orderGroup, RewardDescription reward, PromotionFilterContext filterContext)
Parameters
Type Name Description
IOrderForm orderForm

The order

IOrderGroup orderGroup

The order group

RewardDescription reward

The reward to apply.

PromotionFilterContext filterContext

The promotion filter context.

AddToOrder(IEnumerable<PromotionInformation>, IOrderForm)

Add promotionInformations to orderForm

Declaration
protected virtual void AddToOrder(IEnumerable<PromotionInformation> promotionInformations, IOrderForm orderForm)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<PromotionInformation> promotionInformations

The promotion informations

IOrderForm orderForm

The order form

ApplyReward(RewardDescription, Int32, PromotionProcessorContext)

Applies the reward.

Declaration
public void ApplyReward(RewardDescription reward, int remainingRedemptions, PromotionProcessorContext context)
Parameters
Type Name Description
RewardDescription reward

The reward to apply.

System.Int32 remainingRedemptions

The number of remaining redemptions.

PromotionProcessorContext context

The promotion processor context for the promotion applicator.

CreateAdditionalInformation(PromotionInformation, IOrderForm, PromotionData, IOrderGroup)

Manage additional information for a promotion. If no such details already exists and there is a registered IAdditionalPromotionInformationCreator then the creator will be used for creating and setting the AdditionalInformation value for the PromotionInformation.

Declaration
protected virtual void CreateAdditionalInformation(PromotionInformation promotionInformation, IOrderForm orderForm, PromotionData promotionData, IOrderGroup orderGroup)
Parameters
Type Name Description
PromotionInformation promotionInformation

The promotion information.

IOrderForm orderForm

The order form.

PromotionData promotionData

The promotion

IOrderGroup orderGroup

The order group.

CreateInformation(RewardDescription, IOrderForm, IOrderGroup, PromotionFilterContext)

Creates list of promotion information.

Declaration
protected virtual IEnumerable<PromotionInformation> CreateInformation(RewardDescription reward, IOrderForm orderForm, IOrderGroup orderGroup, PromotionFilterContext filterContext)
Parameters
Type Name Description
RewardDescription reward

The RewardDescription describing the reward for the applied promotion.

IOrderForm orderForm

The order form.

IOrderGroup orderGroup

The order group.

PromotionFilterContext filterContext

The filter context, containing the relevant data added using AddCouponCode(Guid, String) and AddVisitorGroup(ContentReference, Guid).

Returns
Type Description
System.Collections.Generic.IEnumerable<PromotionInformation>

EvaluatePromotion(PromotionData, PromotionProcessorContext)

Evaluates the promotionData for context.OrderForm using PromotionProcessorResolver.

Declaration
public RewardDescription EvaluatePromotion(PromotionData promotionData, PromotionProcessorContext context)
Parameters
Type Name Description
PromotionData promotionData

The promotion to evaluate.

PromotionProcessorContext context

Promotion processor context

Returns
Type Description
RewardDescription

The evaluated RewardDescription.

Exceptions
Type Condition
System.ArgumentNullException

promotion model is null.

System.NotImplementedException

The promotionData has no promotion processor.

GetRewardApplicator(PromotionData)

Gets the reward applicator based on the promotion's DiscountType.

Declaration
protected virtual RewardApplicatorBase GetRewardApplicator(PromotionData promotion)
Parameters
Type Name Description
PromotionData promotion

The promotion.

Returns
Type Description
RewardApplicatorBase

A EntryRewardApplicator or an OrderRewardApplicator depending on the promotion discount type.

Exceptions
Type Condition
System.NotImplementedException