Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Promotion exclusions

Describes how to prevent promotions from being combined with other promotions in Optimizely Customized Commerce.

You can determine which promotions cannot be combined with other promotions. For example, you are running a 20% off automotive supplies sale. Customers should not be able to combine this promotion with the Get cheapest item 50% off promotion on the same item.

Use order and unit-level exclusions

The Customized Commerce API supports both order-level and unit (item)-level exclusions. The components mentioned here are available in the EPiServer.Commerce.Marketing namespace.

Set the desired action through the ExclusionLevel property on the PromotionEngineSettings passed when running the PromotionEngine. Here are examples of using exclusion levels with the PromotionEngine.

Call the PromotionEngine directly

var cart = ServiceLocator.Current.GetInstance<IOrderRepository>().LoadOrCreateCart<Cart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName);
    ServiceLocator.Current.GetInstance<IPromotionEngine>().Run(cart, new PromotionEngineSettings() { ExclusionLevel = ExclusionLevel.Unit }));

 Use the ApplyDiscounts extension method

var cart = ServiceLocator.Current.GetInstance<IOrderRepository>().LoadOrCreateCart<ICart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName);
    cart.ApplyDiscounts(_promotionEngine, new PromotionEngineSettings() { ExclusionLevel = ExclusionLevel.Unit });

You can find another sample implementation in the Optimizely QuickSilver sample site, in the CartService class.

Order level exclusion

ExclusionLevel.Order, the default setting, ensures that two promotions excluding each other are not applied within the same OrderGroup. If they are both applied, the higher priority promotion is used, while the other promotion is ignored.

To exclude promotions, set a list of ContentReference to the ExcludedItems property of the PromotionData. The following samples illustrate this.

promotionData.ExcludedItems.Add(campaignLink);
    promotionData.ExcludedItems.Add(anotherPromotionLink);

Three types of ContentReference can be added to the ExcludedItems property:

  • The SalesCampaign.CampaignRoot. This promotion cannot be combined with any other promotions.
  • A campaign's ContentLink. This promotion cannot be combined with any promotions in that campaign.
  • A promotion's ContentLink. This promotion cannot be combined with that specific promotion.

Unit level exclusion

Use ExclusionLevel.Unit with promotions whose DiscountType value is LineItem.

📘

Note

If you use ExclusionLevel.Unit with any promotion type other than LineItem, its behavior is the same as ExlusionLevel.Order.

Unit level exclusion mean that two promotions that exclude each other are both applied in an OrderGroup.

As with Orders, you exclude promotions by adding ContentReferences to the ExcludedItems list.

promotionData.ExcludedItems.Add(campaignLink);
    promotionData.ExcludedItems.Add(anotherPromotionLink);

Example

Preconditions

  • Promotion P1 is “Buy 3 of product A and get a 10% discount on 1 product A”.
  • Promotion P2 is “Get 5% off product A”.
  • P1 has a higher priority than P2.
  • An order group has the following line item: SKU = A, quantity = 10.

If either P1 or P2 excludes the other

  • P1 gives one unit a 10% discount.
  • The 2 other units used in the P1 promotion are charged full price.
  • The remaining 7 units are available for P2, each receiving a 5% discount.

📘

Note

The sequence in which promotions are executed is determined by their priority.