November Happy Hour will be moved to Thursday December 5th.

Class PromotionProcessorBase<TPromotionData>

Responsible for evaluating if a promotion is valid for a specific IOrderForm.

Implements
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: 13.30.0
Syntax
[CLSCompliant(false)]
public abstract class PromotionProcessorBase<TPromotionData> : IPromotionProcessor where TPromotionData : PromotionData
Type Parameters
Name Description
TPromotionData

Constructors

PromotionProcessorBase()

Declaration
protected PromotionProcessorBase()

Properties

Priority

Gets the priority of this processor. In case there are multiple processors which can handle a promotion, the one with highest priority will be used.

Declaration
public virtual int Priority { get; }
Property Value
Type Description
System.Int32

PromotionDataType

The type this processor can handle.

Declaration
public Type PromotionDataType { get; }
Property Value
Type Description
System.Type

Methods

CanBeFulfilled(TPromotionData, PromotionProcessorContext)

Verify that the current promotion can potentially be fulfilled

Declaration
protected virtual bool CanBeFulfilled(TPromotionData promotionData, PromotionProcessorContext context)
Parameters
Type Name Description
TPromotionData promotionData

The promotion to evaluate.

PromotionProcessorContext context

The context for the promotion processor evaluation.

Returns
Type Description
System.Boolean

true if the current promotion can potentially be fulfilled; otherwise, false.

Remarks

This method is intended to be a very quick pre-check to avoid doing more expensive operations. Used to verify basic things, for example a Buy-3-pay-for-2 promotion needs at least three items in the cart. If we have less than three we can skip further processing.

Evaluate(TPromotionData, PromotionProcessorContext)

Evaluates a promotion against an order form. Implementations should use context.OrderForm for evaluations.

Declaration
protected abstract RewardDescription Evaluate(TPromotionData promotionData, PromotionProcessorContext context)
Parameters
Type Name Description
TPromotionData promotionData

The promotion to evaluate.

PromotionProcessorContext context

The context for the promotion processor evaluation.

Returns
Type Description
RewardDescription

A RewardDescription telling whether the promotion was fulfilled, which items the promotion was applied to and to which amount.

Evaluate(PromotionData, PromotionProcessorContext)

Evaluates a promotion. Implementations should use context.OrderForm when evaluating promotions

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

The promotion model.

PromotionProcessorContext context

The context for the promotion processor evaluation.

Returns
Type Description
RewardDescription

The reward for a promotion.

Remarks

Any implementation of this that applies to a PromotionData that has an System.Collections.Generic.IList<T> property must consider and plan for values where the amount might be zero for some or all currencies.

GetLineItems(IOrderForm)

Get all line items included in an order form, except gift items.

Declaration
public virtual IEnumerable<ILineItem> GetLineItems(IOrderForm orderForm)
Parameters
Type Name Description
IOrderForm orderForm

The order form.

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

All line items included in the specified order form.

GetPromotionItems(TPromotionData)

Gets information about the settings for a specific instance of a promotion type. Used when displaying promotion information to a site visitor/shopper.

Declaration
protected abstract PromotionItems GetPromotionItems(TPromotionData promotionData)
Parameters
Type Name Description
TPromotionData promotionData

The promotion data to get items for.

Returns
Type Description
PromotionItems

The promotion condition and reward items.

Remarks

This method is intended to be used on a site to display information about a promotion to a visitor/shopper.

It is never used during the evaluation of the promotion, it only exists to provide information about the settings for this instance of a promotion type. So a use case for this could be that you have a "Buy 3 get the cheapest for one for free" promotion. And you want to display information to the visitor/shopper that "If you buy three items from the category cooking books, you will get the cheapest one for free".

This method should not be called explicitly from the site code, but will be called from the IPromotionEngine extension method GetPromotionItemsForCampaign.

GetPromotionItems(PromotionData)

Gets information about the settings for a specific instance of a promotion type. Used when displaying promotion information to a site visitor/shopper.

Declaration
public virtual PromotionItems GetPromotionItems(PromotionData promotionData)
Parameters
Type Name Description
PromotionData promotionData

The promotion data to get items for.

Returns
Type Description
PromotionItems

The promotion condition and reward items.

Remarks

This method is intended to be used on a site to display information about a promotion to a visitor/shopper.

It is never used during the evaluation of the promotion, it only exists to provide information about the settings for this instance of a promotion type. So a use case for this could be that you have a "Buy 3 get the cheapest for one for free" promotion. And you want to display information to the visitor/shopper that "If you buy three items from the category cooking books, you will get the cheapest one for free".

This method should not be called explicitly from the site code. It will be called from the IPromotionEngine extension method GetPromotionItemsForCampaign.

NotFulfilledRewardDescription(TPromotionData, PromotionProcessorContext, FulfillmentStatus)

Not fulfilled reward description. Will be returned when CanBeFulfilled is false.

Declaration
protected virtual RewardDescription NotFulfilledRewardDescription(TPromotionData promotionData, PromotionProcessorContext context, FulfillmentStatus fulfillmentStatus)
Parameters
Type Name Description
TPromotionData promotionData

The promotion that was evaluated.

PromotionProcessorContext context

The context for the promotion processor evaluation.

FulfillmentStatus fulfillmentStatus

The fulfillment level of the promotion.

Returns
Type Description
RewardDescription

A RewardDescription for the not fulfilled promotion.

Implements