Pricing service methods

Current version: 10.2

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:

GetProductPricesResult GetProductPrices(GetProductPricesRequest request)

Parameters:

RequestResponse
request.ProductId -

Required.

RequestResponse
Request.UserId - 

Prices typically vary depending on the actual user.

RequestResponse
 Request.CurrencyCode -

Required.

RequestResponse
Request.Location - 

Prices often depend on the location. Location can be a city or a state.

RequestResponse
Request.Quantity - 

If not specified, quantity is assumed to be 1.

RequestResponse
Request.DateTime - 

Needed when campaigns promote products at discount prices within a certain period of time.

RequestResponse
Request.ShopName - 

Multishop support.

RequestResponse
Request.PriceTypeIds - 

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 PriceTypeIds depends on the specific Connect provider implementation.

Returns:

RequestResponse
result.Prices -

A collection of price objects.

RequestResponse
result.ExternalSystem Messages -

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:

RequestResponse
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:

GetProductBreakPricesResult GetProductBreakPrices(GetProductBreakPricesRequest request)

Parameters:

RequestResponse
request.ProductId -

Required.

RequestResponse
Request.UserId - 

Prices typically vary depending on the actual user.

RequestResponse
 Request.CurrencyCode -

Required.

RequestResponse
Request.Location - 

Prices often depend on the location. Location can be a city or a state.

RequestResponse
Request.Quantity - 

If not specified, quantity is assumed to be 1.

RequestResponse
Request.DateTime - 

Needed when campaigns promote products at discount prices within a certain period of time.

RequestResponse
Request.ShopName - 

Multishop support.

Returns:

RequestResponse
result.Prices -

A collection of price objects.

RequestResponse
result.ExternalSystem Messages -

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:

RequestResponse
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:

GetCartPriceResult GetCartPrice(GetCartPriceRequest request)

Parameters:

RequestResponse
request.Cart -

Required.

RequestResponse
request.UserId - 

Prices typically vary depending on the actual user.

RequestResponse
 Request.CurrencyCode -

Required.

RequestResponse
Request.Location - 

Prices often depend on the location. Location can be a city or a state.

RequestResponse
Request.ShopName - 

Multishop support.

RequestResponse
Request.DateTime - 

Needed when campaigns promote products at discount prices within a certain period of time.

Returns:

RequestResponse
result.Cart -

An instance of a Total.

RequestResponse
result.ExternalSystem Messages -

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:

RequestResponse
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:

GetSupportedCurrenciesResult GetSupportedCurrencies([NotNull] GetSupportedCurrenciesRequest request)

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:

RequestResponse
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:

ServiceProviderResult CurrencyChosen(CurrencyChosenRequest request)

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:

RequestResponse
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:

GetEligiblePromotionIdsResult GetEligiblePromotionIds( GetEligiblePromotionIdsRequest request)

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:

RequestResponse
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:

GetProductPromotionDescriptionResult GetProductPromotionDescription(GetProductPromotionDescriptionRequest request)

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:

RequestResponse
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetProductPromotionDescriptionRequest()
{
    PromotionIds = new List<string> { "Promotion001", "Promotion002" },
    CustomerId = "TestCustomer"
};
var result = provider.GetProductPromotionDescription(request);

Do you have some feedback for us?

If you have suggestions for improving this article,