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

Class PromotionEngine

Evaluates the condition on all active promotions and gives reward to specific orders when the conditions are fulfilled.

Inheritance
System.Object
PromotionEngine
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
public class PromotionEngine : IPromotionEngine

Constructors

PromotionEngine(PromotionEngineContentLoader, IRedemptionLimitService, PromotionFilters, PromotionApplicator, ILineItemCalculator, IReturnLineItemCalculator, IShippingCalculator, IOrderFormCalculator, IEntryFilter)

Declaration
[Obsolete("This constructor is no longer used, use the one with IMarketService instead. Will remain at least until May 2019.")]
public PromotionEngine(PromotionEngineContentLoader promotionEngineContentLoader, IRedemptionLimitService redemptionLimitService, PromotionFilters promotionFilters, PromotionApplicator promotionExecutor, ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator, IShippingCalculator shippingCalculator, IOrderFormCalculator orderFormCalculator, IEntryFilter entryFilter)
Parameters
Type Name Description
PromotionEngineContentLoader promotionEngineContentLoader
IRedemptionLimitService redemptionLimitService
PromotionFilters promotionFilters
PromotionApplicator promotionExecutor
ILineItemCalculator lineItemCalculator
IReturnLineItemCalculator returnLineItemCalculator
IShippingCalculator shippingCalculator
IOrderFormCalculator orderFormCalculator
IEntryFilter entryFilter

PromotionEngine(PromotionEngineContentLoader, IRedemptionLimitService, PromotionFilters, PromotionApplicator, ILineItemCalculator, IReturnLineItemCalculator, IShippingCalculator, IOrderFormCalculator, IEntryFilter, IMarketService)

Creates a new instance of a PromotionEngine.

Declaration
[Obsolete("This constructor is no longer used, use the one with IPromotionExcludedCatalogItemService instead. Will remain at least until May 2019.")]
public PromotionEngine(PromotionEngineContentLoader promotionEngineContentLoader, IRedemptionLimitService redemptionLimitService, PromotionFilters promotionFilters, PromotionApplicator promotionExecutor, ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator, IShippingCalculator shippingCalculator, IOrderFormCalculator orderFormCalculator, IEntryFilter entryFilter, IMarketService marketService)
Parameters
Type Name Description
PromotionEngineContentLoader promotionEngineContentLoader

The service used to load existing promotions and other reference data.

IRedemptionLimitService redemptionLimitService

The redemption limits service.

PromotionFilters promotionFilters

Removes any non available promotions.

PromotionApplicator promotionExecutor

Evaluates promotions, applies reward for promotions.

ILineItemCalculator lineItemCalculator

The line item calculator.

IReturnLineItemCalculator returnLineItemCalculator

The return line item calculator.

IShippingCalculator shippingCalculator

The shipping calculator.

IOrderFormCalculator orderFormCalculator

The order form calculator.

IEntryFilter entryFilter

The entry filter.

IMarketService marketService

The market service.

PromotionEngine(PromotionEngineContentLoader, IRedemptionLimitService, PromotionFilters, PromotionApplicator, ILineItemCalculator, IReturnLineItemCalculator, IShippingCalculator, IOrderFormCalculator, IEntryFilter, IMarketService, IPromotionExcludedCatalogItemService)

Creates a new instance of a PromotionEngine.

Declaration
public PromotionEngine(PromotionEngineContentLoader promotionEngineContentLoader, IRedemptionLimitService redemptionLimitService, PromotionFilters promotionFilters, PromotionApplicator promotionExecutor, ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator, IShippingCalculator shippingCalculator, IOrderFormCalculator orderFormCalculator, IEntryFilter entryFilter, IMarketService marketService, IPromotionExcludedCatalogItemService promotionExcludedCatalogItemService)
Parameters
Type Name Description
PromotionEngineContentLoader promotionEngineContentLoader

The service used to load existing promotions and other reference data.

IRedemptionLimitService redemptionLimitService

The redemption limits service.

PromotionFilters promotionFilters

Removes any non available promotions.

PromotionApplicator promotionExecutor

Evaluates promotions, applies reward for promotions.

ILineItemCalculator lineItemCalculator

The line item calculator.

IReturnLineItemCalculator returnLineItemCalculator

The return line item calculator.

IShippingCalculator shippingCalculator

The shipping calculator.

IOrderFormCalculator orderFormCalculator

The order form calculator.

IEntryFilter entryFilter

The entry filter.

IMarketService marketService

The market service.

IPromotionExcludedCatalogItemService promotionExcludedCatalogItemService

The reference converter.

Methods

ClearPromotionsAndDiscountAmounts(IOrderForm, PromotionProcessorContext)

Clears any existing discount amounts on all ILineItems and IShipment in the order and removes any existing promotions from the IOrderForm.

Declaration
protected virtual void ClearPromotionsAndDiscountAmounts(IOrderForm orderForm, PromotionProcessorContext processorContext)
Parameters
Type Name Description
IOrderForm orderForm

The order form holding the promotions to be removed.

PromotionProcessorContext processorContext

The promotion processor context for the promotion applicator.

CreatePromotionContext(IOrderGroup, IOrderForm)

Creates the promotion processor context.

Declaration
[Obsolete("THIS METHOD WILL GIVE INVALID REDEMPTION INFORMATION CAUSING INCORRECT DISCOUNTS. Use the overload that takes a Func<PromotionData, int>. This method will remain at least until July 2019.")]
protected virtual PromotionProcessorContext CreatePromotionContext(IOrderGroup orderGroup, IOrderForm orderForm)
Parameters
Type Name Description
IOrderGroup orderGroup

The order group.

IOrderForm orderForm

The order form.

Returns
Type Description
PromotionProcessorContext

A PromotionProcessorContext

CreatePromotionContext(IOrderGroup, IOrderForm, Func<PromotionData, Int32>)

Creates the promotion processor context.

Declaration
protected virtual PromotionProcessorContext CreatePromotionContext(IOrderGroup orderGroup, IOrderForm orderForm, Func<PromotionData, int> getRedemptionLimit)
Parameters
Type Name Description
IOrderGroup orderGroup

The order group.

IOrderForm orderForm

The order form.

System.Func<PromotionData, System.Int32> getRedemptionLimit

A func that returns the redemption limit for given promotion.

Returns
Type Description
PromotionProcessorContext

A PromotionProcessorContext

Evaluate(IEnumerable<ContentReference>, IMarket, Currency, RequestFulfillmentStatus)

Gets the information about all promotions related to a multiple entries but individually evaluated

Declaration
public IEnumerable<RewardDescription> Evaluate(IEnumerable<ContentReference> entryLinks, IMarket market, Currency currency, RequestFulfillmentStatus requestFulfillmentStatus)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<EPiServer.Core.ContentReference> entryLinks

The entries to get the promotion information about.

IMarket market

The market.

Currency currency

The currency.

RequestFulfillmentStatus requestFulfillmentStatus

The request fulfillment status.

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

A list of RewardDescription giving us the reward information associated to the list of EPiServer.Core.ContentReference

GetCampaignFolderRoot()

Get the link to the campaign folder root.

Declaration
protected virtual ContentReference GetCampaignFolderRoot()
Returns
Type Description
EPiServer.Core.ContentReference

The content link to the campaign folder root.

Run(IOrderGroup, PromotionEngineSettings)

Checks the condition for all active promotions, and gives awards for the promotions where the condition has been fulfilled. Promotions with higher priority (lower Priority value) will be evaluated first and all excluded promotions will not be evaluated.

Declaration
public virtual IEnumerable<RewardDescription> Run(IOrderGroup orderGroup, PromotionEngineSettings settings)
Parameters
Type Name Description
IOrderGroup orderGroup

The order group which will receive rewards.

PromotionEngineSettings settings

The settings for this run of the engine.

Returns
Type Description
System.Collections.Generic.IEnumerable<RewardDescription>
Remarks

Will return RewardDescriptions that has the same status as any of the RequestedStatuses.

Implements

Extension Methods