SaaS CMS has officially launched! Learn more now.

Class MarketingContext

Class serves as a mediator for all the functions that can be performed in the marketing system.

Inheritance
System.Object
MarketingContext
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: Mediachase.Commerce.Marketing
Assembly: Mediachase.Commerce.dll
Version: 11.8.3
Syntax
[Obsolete("Use promotion system in EPiServer.Commerce.Marketing instead. Will be removed in a future major release, but not earlier than August 2018.")]
public class MarketingContext

Properties

Current

Gets the current.

Declaration
public static MarketingContext Current { get; }
Property Value
Type Description
MarketingContext

The current.

MarketingProfileContext

Gets the marketing profile context. Marketing profile defines context that is used by the marketing engine.

Context Objects:

  • Session.Cart
  • Session.Attributes
  • Session.Coupons
  • Membership.Profile
  • Membership.User
  • Customer.Segments
Declaration
public Dictionary<string, object> MarketingProfileContext { get; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, System.Object>

The marketing profile.

MetaDataContext

Gets or sets the meta data context.

Declaration
public static MetaDataContext MetaDataContext { get; set; }
Property Value
Type Description
MetaDataContext

The meta data context.

PromotionEntryPopulateFunctionClassInfo

Gets the promotion entry populate function class info.

Declaration
public ClassInfo PromotionEntryPopulateFunctionClassInfo { get; }
Property Value
Type Description
ClassInfo

The promotion entry populate function class info.

Methods

AddCouponToMarketingContext(String)

Adds the coupon to marketing context.

Declaration
public void AddCouponToMarketingContext(string couponCode)
Parameters
Type Name Description
System.String couponCode

The coupon code.

ClearAllCouponInMarketingContext()

Declaration
public void ClearAllCouponInMarketingContext()

EvaluatePromotions(PromotionContext, PromotionItemCollection, PromotionFilter, Dictionary<PromotionDto.PromotionRow, Nullable<Decimal>>, PromotionEntriesSet, IEnumerable<PromotionEntriesSet>, Nullable<Boolean>)

Evaluates the promotions with specified SourceEntriesSet.

Declaration
public PromotionItemCollection EvaluatePromotions(PromotionContext context, PromotionItemCollection promotions, PromotionFilter filter, Dictionary<PromotionDto.PromotionRow, decimal?> entryDiscountApplicationCount, PromotionEntriesSet sourceEntriesSet, IEnumerable<PromotionEntriesSet> entriesSetCollection, bool? checkEntryLevelLimit)
Parameters
Type Name Description
PromotionContext context

The context.

PromotionItemCollection promotions

The promotions.

PromotionFilter filter

The filter.

System.Collections.Generic.Dictionary<PromotionDto.PromotionRow, System.Nullable<System.Decimal>> entryDiscountApplicationCount

The entry discount application count.

PromotionEntriesSet sourceEntriesSet

The source entries set.

System.Collections.Generic.IEnumerable<PromotionEntriesSet> entriesSetCollection

The collection of entries set to apply promotions.

System.Nullable<System.Boolean> checkEntryLevelLimit

If true, check if entry level limit has been reached. If is null, it'll only check for last entries set in entriesSetCollection

Returns
Type Description
PromotionItemCollection

Collection of promotions that were applied. Look inside PromotionContext for actual rewards and for items that have been affected by these promotions.

Remarks

This can return inconsistent result when there are Exclusive promotions. To avoid that use, use the other overload instead.

EvaluatePromotions(PromotionContext, PromotionItemCollection, PromotionFilter, Dictionary<PromotionDto.PromotionRow, Nullable<Decimal>>, IEnumerable<PromotionEntriesSet>, Nullable<Boolean>)

Evaluates the promotions.

Declaration
public PromotionItemCollection EvaluatePromotions(PromotionContext context, PromotionItemCollection promotions, PromotionFilter filter, Dictionary<PromotionDto.PromotionRow, decimal?> entryDiscountApplicationCount, IEnumerable<PromotionEntriesSet> entriesSetCollection, bool? checkEntryLevelLimit)
Parameters
Type Name Description
PromotionContext context

The context.

PromotionItemCollection promotions

The promotions.

PromotionFilter filter

The filter.

System.Collections.Generic.Dictionary<PromotionDto.PromotionRow, System.Nullable<System.Decimal>> entryDiscountApplicationCount

The entry discount application count.

System.Collections.Generic.IEnumerable<PromotionEntriesSet> entriesSetCollection

The collection of entries set to apply promotions.

System.Nullable<System.Boolean> checkEntryLevelLimit

If true, check if entry level limit has been reached. If is null, it'll only check for last entries set in entriesSetCollection

Returns
Type Description
PromotionItemCollection

Collection of promotions that were applied. Look inside PromotionContext for actual rewards and for items that have been affected by these promotions.

Remarks

This can return inconsistent result when there are Exclusive promotions. To avoid that use, use the other overload instead.

EvaluatePromotions(Boolean, PromotionContext, PromotionFilter, Dictionary<PromotionDto.PromotionRow, Nullable<Decimal>>, PromotionEntriesSet, IEnumerable<PromotionEntriesSet>, Nullable<Boolean>)

Evaluates the promotions with specified SourceEntriesSet.

Declaration
public PromotionItemCollection EvaluatePromotions(bool useCache, PromotionContext context, PromotionFilter filter, Dictionary<PromotionDto.PromotionRow, decimal?> entryDiscountApplicationCount, PromotionEntriesSet sourceEntriesSet, IEnumerable<PromotionEntriesSet> entriesSetCollection, bool? checkEntryLevelLimit)
Parameters
Type Name Description
System.Boolean useCache

if set to true [use cache].

PromotionContext context

The context.

PromotionFilter filter

The filter.

System.Collections.Generic.Dictionary<PromotionDto.PromotionRow, System.Nullable<System.Decimal>> entryDiscountApplicationCount

The entry discount application count.

PromotionEntriesSet sourceEntriesSet

The source entries set.

System.Collections.Generic.IEnumerable<PromotionEntriesSet> entriesSetCollection

The collection of entries set to apply promotions.

System.Nullable<System.Boolean> checkEntryLevelLimit

If true, check if entry level limit has been reached.

Returns
Type Description
PromotionItemCollection

Collection of promotions that were applied. Look inside PromotionContext for actual rewards and for items that have been affected by these promotions.

EvaluatePromotions(Boolean, PromotionContext, PromotionFilter, Dictionary<PromotionDto.PromotionRow, Nullable<Decimal>>, IEnumerable<PromotionEntriesSet>, Nullable<Boolean>)

Evaluates the promotions.

Declaration
public PromotionItemCollection EvaluatePromotions(bool useCache, PromotionContext context, PromotionFilter filter, Dictionary<PromotionDto.PromotionRow, decimal?> entryDiscountApplicationCount, IEnumerable<PromotionEntriesSet> entriesSetCollection, bool? checkEntryLevelLimit)
Parameters
Type Name Description
System.Boolean useCache

if set to true [use cache].

PromotionContext context

The context.

PromotionFilter filter

The filter.

System.Collections.Generic.Dictionary<PromotionDto.PromotionRow, System.Nullable<System.Decimal>> entryDiscountApplicationCount

The entry discount application count.

System.Collections.Generic.IEnumerable<PromotionEntriesSet> entriesSetCollection

The collection of entries set to apply promotions.

System.Nullable<System.Boolean> checkEntryLevelLimit

If true, check if entry level limit has been reached.

Returns
Type Description
PromotionItemCollection

Collection of promotions that were applied. Look inside PromotionContext for actual rewards and for items that have been affected by these promotions.

GetAllRegisteredCoupons()

Declaration
public IEnumerable<string> GetAllRegisteredCoupons()
Returns
Type Description
System.Collections.Generic.IEnumerable<System.String>

GetCustomerSegments(Dictionary<String, Object>, Guid, Guid)

Returns customer segments for specified customer or organization.

Declaration
public List<int> GetCustomerSegments(Dictionary<string, object> context, Guid customerPrincipalId, Guid organizationPrincipalId)
Parameters
Type Name Description
System.Collections.Generic.Dictionary<System.String, System.Object> context

The context. Should include ContextConstants.CustomerProfile of type ProfileBase

System.Guid customerPrincipalId

The customer principal id.

System.Guid organizationPrincipalId

The organization principal id.

Returns
Type Description
System.Collections.Generic.List<System.Int32>

int list of customer segment ids

GetCustomerSegments(Guid, Guid)

Returns customer segments for specified customer or organization using current MarketingProfileContext.

Declaration
public List<int> GetCustomerSegments(Guid customerPrincipalId, Guid organizationPrincipalId)
Parameters
Type Name Description
System.Guid customerPrincipalId

The customer principal id.

System.Guid organizationPrincipalId

The organization principal id.

Returns
Type Description
System.Collections.Generic.List<System.Int32>

GetMarketingHelper(Boolean)

Gets the marketing helper.

Declaration
public MarketingHelper GetMarketingHelper(bool useCache)
Parameters
Type Name Description
System.Boolean useCache

if set to true [use cache].

Returns
Type Description
MarketingHelper

GetMarketingSystemVersion(out Int32, out Int32, out Int32, out DateTime)

Declaration
[Obsolete("This method is no longer used. Will remain at least until August 2018.")]
public static int GetMarketingSystemVersion(out int major, out int minor, out int patch, out DateTime installDate)
Parameters
Type Name Description
System.Int32 major
System.Int32 minor
System.Int32 patch
System.DateTime installDate
Returns
Type Description
System.Int32

ValidateExpression(String, String, PromotionContext)

Validates the expression.

Declaration
public ValidationResult ValidateExpression(string key, string expr, PromotionContext context)
Parameters
Type Name Description
System.String key

The key.

System.String expr

The expr.

PromotionContext context

The context.

Returns
Type Description
ValidationResult

ValidateExpression(String, String, IDictionary<String, Object>)

Validates the expression using the validator configured in the marketing settings.

Declaration
public ValidationResult ValidateExpression(string key, string expr, IDictionary<string, object> context)
Parameters
Type Name Description
System.String key

The key.

System.String expr

The expr.

System.Collections.Generic.IDictionary<System.String, System.Object> context

The context.

Returns
Type Description
ValidationResult

Validation results, which will either say it is successfully passed or not.