Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
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 describes the pricing provider feature in Episerver Commerce. The pricing logic is provider-based, so it can call an ERP system or another external system directly to get a product's price data. It lets you develop a custom pricing module in the system, and lets you use price data in all display and calculation locations in the platform. The existing pricing data is isolated into a replaceable module, and upgrades always use this provider.
Classes in this topic are available in the following namespaces:
The pricing providers are the access points for accessing and editing price data. The following pieces of data in the price values determine when a price is applicable:
Price values are specific to a single market, specified in the MarketId property of IPriceValue. In implementations that do not use multi-market functionality, prices are specific to the default market.
Prices are specific to a single currency, specified in the Money.Currency property within IPriceValue.UnitPrice.
Automatic currency conversion is not supported directly within the pricing system. If automatic conversions between currencies are needed, a scheduled task should be created to convert prices from a base currency with prices managed by a user or ERP.
You can limit prices to purchases of a minimum quantity with the IPriceValue.MinQuantity property. Because the commerce system permits fractional quantities, set the minimum quantity for a default price to 0, and not 1. Set prices that do not vary by quantity to a minimum quantity of 0.
Each price is limited by date and time, to allow prices changes to take effect in the future, and to ensure that past orders can be recalculated based on price at purchase time for processing returns.
Each price value may be available to all customers, individual customers, or all customers in a specific customer group. You set customer-specific pricing in the CustomerPricing property of IPriceValue, which is of type CustomerPricing.
You set the price group for a customer in an organization associated with the customer, or directly in the customer contact. If you associate a customer with an organization, and that organization has a non-empty customer group value for Organization.OrgCustomerGroup value, the value of that property is the customer's effective customer group. If the customer does not have an organization-level customer group, the customer group is defined by CustomerContact.CustomerGroup.
The CustomerContact.EffectiveCustomerGroup property encapsulates the logic of determining the customer's price group. You can define additional price types in ecf.catalog.config. See PriceType examples for information about working with price type features.
Multiple price values are frequently available for a particular product, market, currency, quantity, date, and customer. For example, a purchase of a dozen items may match prices with:
When multiple prices are available for a purchase, the lowest available price is used.
Two services are available for interacting with price data. The IPriceService API is typically used by back-end order processing to fetch prices for actual use, while the IPriceDetailService is typically used in user interface elements to display and edit prices.
The difference between these APIs is that the IPriceService works with optimized sets of price data, while the IPriceDetailService works with exact user input. The optimization in the IPriceService removes prices that will never be used, and trims or splits prices that overlap.
For example, if a price manager sets three prices that are identical except:
The second and third prices are redundant. Any order that matches either the second or third price also matches the first, and the first price is used because it is lower. If these prices are saved and then fetched via the IPriceDetailService, all three prices are returned. If the prices are fetched via the IPriceService, only the first price is returned, because it will never be used for processing.
The optimized service also may make some modifications to prices. For example, if a price manager sets two prices that are identical except:
Then the optimized price service splits the first price into one value that is only for January, and one value that is for March through December, and leave the price for February intact.
Use the price detail service to access price data in edit mode. A dojo component in edit mode might need price information, and the IPriceDetailService should be used in that case. IPriceDetailService should not be used on the public site.
To fetch prices, a List method is used with a content reference and optional filter. The content reference has contextual behavior:
The Save and Delete methods insert/update or delete the specified values. Values are identified by the IPriceDetailValue.PriceValueId property, which should be left as 0 when creating a new value.
Values edited via the detail service are immediately incorporated into the optimized service. If a custom detail service is implemented, and it does not have its own mechanism for synchronizing with a custom optimized service, the detail service must call IPriceService.ReplicatePriceDetailChanges on edits to update the optimized data store. Calls to ReplicatePriceDetailChanges must include a collection of the catalog entries affected by the changes, and price values associated with those entries. If you add one price value to one price entry, then you must call ReplicatePriceDetailChanges with a key to the associated entry, and each price value associated with that entry after the change.
Use the optimized price service to access price data when you use price values for business processing. The default implementation of IPriceService uses ISynchronizedObjectInstanceCache to prevent unnessesary database calls.
Optimized prices are fetched by catalog entry. There is no contextual behavior for the optimized service based on the type of the entry; only prices directly associated with the target entry are returned, regardless whether it is product, variant, or other entry type.
The GetCatalogEntryPrices methods return full sets of price data for the specified catalog entries.
The GetPrices methods return filtered data for the specified catalog entries. You can use the CatalogKeyAndQuantity class to get prices for a multiple entries, with different quantities for each, in a single request.
When you save prices via the optimized price service, include price values for the specified catalog entries. The SetCatalogEntryPrices methods replace price values for the specified catalog entries; if no price values are specified, then the pricing data is cleared for the entry.
Values edited via the optimized service are immediately incorporated into the detail service. If a custom optimized service is implemented, and it does not have its own mechanism for synchronizing with a custom detail service, the detail service must call IPriceDetailService.ReplicatePriceServiceChanges on edits to update the optimized data store. When you replicate optimized prices into the detail service, values for the edited catalog entries are replaced in the detail service, which may eliminate redundant values or create less intuitive data when price values are split. For this reason, use the price detail service as the service to use for editing, unless this behavior is specifically desired.
Use the PriceFilter class to describe a filter for a pricing request.
The ReturnCustomerPricing property is typically false when fetching price data for business processing, because only the final price value is usually needed. It is not typically useful to set this value to true with doing business processing; if you need additional data about varying prices by customer, consider using the price detail service.
Last updated: Oct 12, 2015