Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
This topic provides examples of using the ECF API to work with multi-market and warehouse features to
Examples of how to change and set markets to display.
Example: Getting all available markets
public IEnumerable GetAvailableMarkets()
{
var marketService = ServiceLocator.Current.GetInstance<IMarketService>();
// Get all available markets.
return marketService.GetAllMarkets();
}
Example: Getting current markets
public IMarket GetCurrentMarket()
{
var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
// Get current markets.
return currentMarketService.GetCurrentMarket();
}
Example: Setting current markets
public void SetCurrentMarket(MarketId marketId)
{
var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
// Get current markets.
currentMarketService.SetCurrentMarket(marketId);
}
Examples of how to display the entries listed with pricing and discount for a selected market.
Example: Getting the price for an entry per market
public Price GetSalePrice(Entry entry, decimal quantity)
{
var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
var currentMarket = currentMarketService.GetCurrentMarket();
return StoreHelper.GetSalePrice(entry, quantity, currentMarket);
}
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 12, 2015