This post is out of date.

Applying A Promotion To The Marketing Engine In Episerver Commerce

In previous articles, I've talked about Using The New Promotions Engine in Episerver Commerce and The New Order Repository In Commerce. Also, don't forget you need to read this as well How To Enable Beta Features In Episerver. That covers a lot of the basics but it fails to cover how a content editor can create a campaign and discount within Episerver.

Open Commerce Manager

episerver_commerce_manager_marketing Select the marketing tab

Create a new campaign

episerver_commerce_sales_campaign Click on the plus button on the top left-hand corner of the page and add a campaign name. episerver_commerce_creating_a_sales_campaign At this stage, you will have to fill in the appropriate campaign details. I won't cover this bit but it is worth noting that if you want extra campaign details you might want to create a custom campaign. You can do this by creating a class that extends the default SalesCampaign type. An example snippet to create a custom campaign can be seen below:

        DisplayName = "Test Campaign",
        GUID = "3fd81fcb-bfac-4ebc-a7dd-4d7e200f2e2b",
        Description = "Test Campaign")]
    public class TestCampaignData : SalesCampaign

Creating a Discount

After we have created a campaign, click the top left plus again and click discount. episerver_commerce_manager_adding_a_discount From here you will need to pick out of all the discount types you have created in your solution via code. episerver_commerce_picking_a_discount These discounts work exactly like a page or a block so the properties you will need to fill in for your promotion will be based on the properties you defined on your discount. episerver_commerce_campaign_page

Activating The Campaign and promotion

One important tip that can lead to a source of frustration is to forget to enable the active checkbox on the campaign AND all the discounts within them. If you do not activate the promotion it will not be triggered when the promotion engine is run. episerver_commerce_activating_promotion

Job Done

After you have created your campaign and discount and you have the code to apply the discounts (see below) you should have everything set-up. You will want to add this code in the add line item and update line item areas in your basket code.

   var cart = orderRepository.Create<Cart>(Guid.NewGuid(), Cart.DefaultName);	
   var orderGroup = ((IOrderGroup)cart);	

When you run this code you should be able to hit a breakpoint in your promotions processors evaluate method. If the breakpoint never gets hit then make sure the campaign and promotion are active AND they have a valid start and end dates.


In today's guide, we've walked through how to create a campaign and a promotion within the Episerver commerce manager. The process is very simple but there are a few hidden gotcha's you should be aware of.

submit to reddit

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top