HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunitySubmit a ticketLog In

Hide promotion types

Describes how to determine which promotion types appear on the Edit Discount view in the Optimizely Customized Commerce user interface for managing campaigns and discounts (promotions).

Hiding promotions can be useful in scenarios where you want to prevent merchandisers and marketers from creating new discounts of specific types.

The components mentioned here are available in the EPiServer.Commerce.Marketing namespace.

To hide promotions, use the PromotionTypeHandler class.

  • DisablePromotions. Disable promotion types. This setting will prevent these promotions to appear when editing discounts.
  • EnablePromotions. Enable promotion types.
  • DisableBuiltinPromotions. Disable all built-in promotion types. If this is set, only custom promotions appear in the user interface.
  • GetAllPromotionTypes. Get all of your site's promotion types.

Disable the BuyQuantityGetFreeItems promotion.

var promotionTypeHandler = ServiceLocator.Current.GetInstance<PromotionTypeHandler>();
    promotionTypeHandler.DisablePromotions(new[] { typeof(BuyQuantityGetFreeItems) });

Re-enable that promotion.

promotionTypeHandler.EnablePromotions(new[] { typeof(BuyQuantityGetFreeItems) });

Disable all built-in promotion types when a site is initialized.

namespace EPiServer.Commerce.Sample.Business.Initialization
        public class InitializationModule : IConfigurableModule
            public void Initialize(InitializationEngine context)
            public void Uninitialize(InitializationEngine context)
            public void ConfigureContainer(ServiceConfigurationContext context)
            private void DisablePromotionTypes(InitializationEngine context)
                var promotionTypeHandler = context.Locate.Advanced.GetInstance<PromotionTypeHandler>();
                // To disable all built-in promotion types