Hide menu Last updated: Sep 07 2017
Area: Episerver Commerce Applies to versions: 11.3 and higher

Promotion exclusions

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.

The Commerce API supports both order-level and unit (that is, item)-level exclusions.

Using exclusions

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

Directly calling the PromotionEngine

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

 Using 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 Episerver QuickSilver sample site, in the CartService class.

Order Level Exclusion

ExclusionLevel.Order, the default setting, insures that two promotions that exclude each other do not get applied within the same OrderGroup. If they are both applied, the higher priority promotion is used, while the other promotion is ignored. See also "Prioritizing discounts" in the Episerver User Guide.

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 as long as they do not affect the same units of an item 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, so they each receive a 5% discount.

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

Comments