- Business Foundation
- Generating typed business foundation classes
- SQL meta-model
- Extending meta-models
- Exporting and importing meta-models
- Working with SQL Records
- Working with entity objects
- Filtering and sorting
- Business meta-model
- Product variants
- Bundles and packages
- Related entries
- Catalog events
- Commerce rendering templates
- Catalog content provider
- Assets and media
- Metadata Plus
- Order system overview
- Order manipulation
- Order processing
- Calculating orders
- Extending order classes
- Changing default implementation
- Rounding totals for different currencies
- Order notifications
- Order events
- Searching for orders
- Order object model and database diagram [Legacy]
- Order management classes [Legacy]
- Order addresses [Legacy]
- Shopping cart [Legacy]
- Checkout process [Legacy]
- Recurring orders [Legacy]
- Changing order number sequence [Legacy]
- Taxes [Legacy]
- EPiServer.Commerce.Sample guideline [Legacy]
- Scheduled Jobs
- Customizing search
- Configuring facets and filters
- Creating a search provider
- Configuring Solr search provider
- Configuring Episerver Find search provider
- Find integration
- Warehouses and inventories
- Workflows and activities
This content is archived. See latest version here.
Last updated: Jul 14 2016
This topic covers how the promotion engine in Episerver Commerce works, and how to use it for calculating discounts on a shopping cart.
Promotion engine flow
Here is an example of how to use the new engine to calculate promotions using the new order API.
var cart = ServiceLocator.Current.GetInstance<IOrderRepository>().LoadOrCreateCart<Cart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName); ServiceLocator.Current.GetInstance<IPromotionEngine>().Run(cart);
Get promotion prices
var promotionEngine = ServiceLocator.Current.GetInstance<IPromotionEngine>(); var currentMarket = ServiceLocator.Current.GetInstance<ICurrentMarket>(); promotionEngine.GetDiscountPrices(entryLink, currentMarket);
Get promotions and items for campaign
Calculate promotions using workflows
You can run the promotion system with the workflow system to calculate and remove promotions. Updated workflow activities use the EPiServer.Commerce.Marketing.IPromotionEngine to make calculations and manipulate the cart.
To use the new promotion system in the workflows, use one of these methods.
- Update Configs\ecf.app.config.
<Features> <add feature="WorkflowsVNext" state="Enabled" type="Mediachase.Commerce.Core.Features.WorkflowsVNext, Mediachase.Commerce" /> </Features> </Application>
- Use the Servicelocator.
var featureSwitch = ServiceLocator.Current.GetInstance<IFeatureSwitch>(); featureSwitch.Features.Add(new WorkflowsVNext()); featureSwitch.EnableFeature(WorkflowsVNext. FeatureWorkflowsVNext);
Prices and rounding
In general, rounding occurs at every stage of the shopping process. Commerce ensures that fractions are distributed as evenly as possible to make the sums correct.
For example: buy 3 for $10. In this case, each line item (assuming three different products) gets $3.3333. But with rounding and "money sprinkling," the actual line item costs are $3.34, $3.33 and $3.33.