Pricing service methods
Service providers are wrapper objects designed to make it easier to interact with Connect pipelines. The providers implement no logic other than calling Connect pipelines. All of the business logic is implemented in the pipeline processors.
The Pricing service provider contains the following methods for interacting with pricing data.
GetProductPrices method
Description: |
Gets the prices for a specific product. | |
Usage: |
Called when Sitecore needs the prices for a specific product. | |
Signature: |
| |
Parameters: | ||
RequestResponse
|
Required. | |
RequestResponse
|
Prices typically vary depending on the actual user. | |
RequestResponse
|
Required. | |
RequestResponse
|
Prices often depend on the location. Location can be a city or a state. | |
RequestResponse
|
If not specified, quantity is assumed to be 1. | |
RequestResponse
|
Needed when campaigns promote products at discount prices within a certain period of time. | |
RequestResponse
|
Multishop support. | |
RequestResponse
|
List of the types of prices to retrieve. If not specified, only the base/list price is returned. Examples include list, break, and sale prices. The actual | |
Returns: | ||
RequestResponse
|
A collection of price objects. | |
RequestResponse
|
Collection of messages from the external system. This is how error conditions can be reported. | |
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var pricingServiceProvider = new PricingServiceProvider();
// Create a GetProductPricesRequest object, specify the product's ID and do not
// specify any price types. Default price type is ListPrice
var request = new GetProductPricesRequest("Audi A8L");
// Call the service provider and receive the result.
var result = pricingServiceProvider.GetProductPrices(request);
// Result prices contains the list price only.
var price = result.Prices.First().Value.Amount;
// You can use the GetProductPrices to get the prices of a specific type.
// The following sample shows an example of retrieving a price of type Customer
// opposed to the default List price type:
// Create a GetProductPricesRequest object, specify the product's ID and price type
// 'Customer'.
request = new GetProductPricesRequest("Audi A8L", "Customer");
// Call service provider and receive the result.
var result2 = pricingServiceProvider.GetProductPrices(request);
// Result prices contains the Customer price only.
var price2 = result.Prices.First().Value.Amount;
GetProductBulkPrices method
Description: |
Gets the bulk prices for a specific product. | |
Usage: |
Called when Sitecore needs the break prices for a specific product. | |
Signature: |
| |
Parameters: | ||
RequestResponse
|
Required. | |
RequestResponse
|
Prices typically vary depending on the actual user. | |
RequestResponse
|
Required. | |
RequestResponse
|
Prices often depend on the location. Location can be a city or a state. | |
RequestResponse
|
If not specified, quantity is assumed to be 1. | |
RequestResponse
|
Needed when campaigns promote products at discount prices within a certain period of time. | |
RequestResponse
|
Multishop support. | |
Returns: | ||
RequestResponse
|
A collection of price objects. | |
RequestResponse
|
Collection of messages from the external system. This is how error conditions can be reported. | |
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var pricingServiceProvider = new PricingServiceProvider();
// Create a GetProductPricesRequest object, specify the product's ID and price type
// 'Customer'. The price type argument is optional and defaults to List.
var request = new GetProductBulkPricesRequest(
new List<string>()
{
"Audi A8L",
"Renault Grand Scenic",
"Skoda Octavia RS"
},
"Customer");
// Call service provider and receive the result.
var result = pricingServiceProvider.GetProductBulkPrices(request);
// Result contains a dictionary of <key, value> pairs, where the key is the
// product ID and the value represent the corresponding Price.
var price = result.Prices["Audi A8L"].Amount;
GetCartTotal method
Description: |
Gets the price for a specific cart. | |
Usage: |
Called when Sitecore needs the price for a specific cart. | |
Signature: |
| |
Parameters: | ||
RequestResponse
|
Required. | |
RequestResponse
|
Prices typically vary depending on the actual user. | |
RequestResponse
|
Required. | |
RequestResponse
|
Prices often depend on the location. Location can be a city or a state. | |
RequestResponse
|
Multishop support. | |
RequestResponse
|
Needed when campaigns promote products at discount prices within a certain period of time. | |
Returns: | ||
RequestResponse
|
An instance of a Total. | |
RequestResponse
|
Collection of messages from the external system. This is how error conditions can be reported. | |
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var cartServiceProvider = new CartServiceProvider();
var pricingServiceProvider = new PricingServiceProvider();
// Create LoadCart request.
var cartRequest = new CreateOrResumeCartRequest("MyShop", "MyCart");
// Call CreateOrResumeCart and get the cart
var cart = cartServiceProvider.CreateOrResumeCart(cartRequest).Cart
// Create a GetCartTotalRequest object, specify the Cart and shop name
var request = new GetCartTotalRequest {Cart = cart, ShopName = "MyShop"};
// Call service provider and receive the result.
var result = pricingServiceProvider.GetCartTotal(request);
// Result contains the updated cart augmented with Total, TaxTotal,
// and TaxSubTotal instances
var cartTotal = result.Cart.Total.Amount;
GetSupportedCurrencies method
Description: |
Gets a list of currencies supported by the ECS. | |
Usage: |
Called when Sitecore needs the list of supported currencies. | |
Signature: |
| |
Parameters: | ||
ShopName – Mandatory The name of the shop. | ||
Returns: | ||
IReadOnlyCollection<string> – A list of all supported currency codes. | ||
SystemMessages - Collection of messages from the external system. | ||
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetSupportedCurrenciesRequest("StarterKit");
var result = provider.GetSupportedCurrencies(request);
if (result.Success)
{
foreach (var currency in result.Currencies)
{
// handle currency.
}
}
CurrencyChosen method
Description: |
Raises the Currency Chosen page event . | |
Usage: |
Called when Sitecore needs to raise the Currency Chosen event. | |
Signature: |
| |
Parameters: | ||
ShopName – Mandatory The name of the shop. | ||
ChosenCurrency – Mandatory The chosen currency code. | ||
Returns: | ||
SystemMessages - Collection of messages from the external system. | ||
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new CurrencyChosenRequest("StarterKit", "USD");
var result = provider.CurrencyChosen(request);
if (!result.Success)
{
foreach (var message in result.SystemMessages)
{
// handle error messages.
}
}
GetEligiblePromotionIds method
Description: |
Retrieves the IDs of promotions that can be applied to a product . | |
Usage: |
Called to retrieve the IDs of promotions that can be applied to a product, for example, on the product details page. | |
Signature: |
| |
Parameters: | ||
Shop – Mandatory The target shop. | ||
ProductId – Mandatory The ID of the product for which promotions should be retrieved. | ||
TargetTime – Optional The time context that will be used to determine which promotions are eligible. | ||
CustomerId – Optional The ID of the customer for which the promotions are being retrieved. | ||
Returns: | ||
PromotionIds - Collection containing the IDs of the promotions that are applicable to the product. | ||
SystemMessages - Collection of messages from the external system. | ||
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetEligiblePromotionIdsRequest()
{
ProductId = "Product001",
CustomerId = "TestCustomer"
};
var result = provider.GetEligiblePromotionIds(request);
GetProductPromotionDescription method
Description: |
Retrieves the description of a list of promotions for a product. | |
Usage: |
Called to retrieve the description of a list of promotions for display on the site. | |
Signature: |
| |
Parameters: | ||
Shop – Mandatory The target shop. | ||
PromotionIds – Mandatory The IDs of the promotions to retrieve. | ||
CustomerId – Optional The ID of the customer for which the promotions are being retrieved. | ||
Returns: | ||
Promotions - Collection containing the requested promotions. | ||
SystemMessages - Collection of messages from the external system. | ||
Exceptions: | ||
No exceptions are thrown by this method. |
Usage example:
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetProductPromotionDescriptionRequest()
{
PromotionIds = new List<string> { "Promotion001", "Promotion002" },
CustomerId = "TestCustomer"
};
var result = provider.GetProductPromotionDescription(request);