Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Navigation [hide] [expand]
ARCHIVED This content is retired and no longer maintained. See the latest version here.

This document provides examples of how to use the ECF API to work with multi-market and warehouse features. Examples covered here are for instance how to change markets, getting prices and discounts for markets, listing warehouses and getting inventories per warehouse.

Multi-market features

Changing market to display

Examples of how to change and set markets to display.

Page Types

Example: Getting all available markets

C#
public IEnumerable GetAvailableMarkets()
{
    var marketService = ServiceLocator.Current.GetInstance<IMarketService>();
    // Get all available markets.
    return marketService.GetAllMarkets();
}

Example: Getting current markets

C#
public IMarket GetCurrentMarket()
{
    var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
    // Get current markets.
    return currentMarketService.GetCurrentMarket();
}

Example: Setting current markets

C#
public void SetCurrentMarket(MarketId marketId)
{
    var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
    // Get current markets.
    currentMarketService.SetCurrentMarket(marketId);
}

Displaying entry listing, prices and discounts per market

Examples of how to display the entries listed with pricing and discount for a selected market.

Page Types

Page Types

Example: Getting the price for an entry per market

C#
public Price GetSalePrice(Entry entry, decimal quantity)
{
    var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
    var currentMarket = currentMarketService.GetCurrentMarket();
    return StoreHelper.GetSalePrice(entry, quantity, currentMarket);
}

Example: Getting discounts per market

C#
public Price GetDiscountPrice(Entry entry)
{
    var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
    var currentMarket = currentMarketService.GetCurrentMarket();
    return StoreHelper.GetDiscountPrice(entry, string.Empty, string.Empty, currentMarket);
}

Last updated: Oct 21, 2014