---
title: "Pricing service methods"
slug: "pricing-service-methods"
abstract: ""
---
# 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.

<details>
<summary><h2>GetProductPrices method</h2></summary>

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

```text
request.ProductId -

```

- :

```text
Request.UserId -

```

- :

```text
Request.CurrencyCode -

```

- :

```text
Request.Location -

```

- :

```text
Request.Quantity -

```

- :

```text
Request.DateTime -

```

- :

```text
Request.ShopName -

```

- :

```text
Request.PriceTypeIds -

```

- **Returns:**:
- :

```text
result.Prices -

```

- :

```text
result.ExternalSystem Messages -

```

- **Exceptions:**:
- :

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;

```

</details>

<details>
<summary><h2>GetProductBulkPrices method</h2></summary>

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

```text
request.ProductId -

```

- :

```text
Request.UserId -

```

- :

```text
Request.CurrencyCode -

```

- :

```text
Request.Location -

```

- :

```text
Request.Quantity -

```

- :

```text
Request.DateTime -

```

- :

```text
Request.ShopName -

```

- **Returns:**:
- :

```text
result.Prices -

```

- :

```text
result.ExternalSystem Messages -

```

- **Exceptions:**:
- :

Usage example:

```csharp
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;

```

</details>

<details>
<summary><h2>GetCartTotal method</h2></summary>

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

```text
request.Cart -

```

- :

```text
request.UserId -

```

- :

```text
Request.CurrencyCode -

```

- :

```text
Request.Location -

```

- :

```text
Request.ShopName -

```

- :

```text
Request.DateTime -

```

- **Returns:**:
- :

```text
result.Cart -

```

- :

```text
result.ExternalSystem Messages -

```

- **Exceptions:**:
- :

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;

```

</details>

<details>
<summary><h2>GetSupportedCurrencies method</h2></summary>

| **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**<br><br>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:

```csharp
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.
    }
}

```

</details>

<details>
<summary><h2>CurrencyChosen method</h2></summary>

| **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**<br><br>The name of the shop. |  |
|  | **ChosenCurrency** **– Mandatory**<br><br>The chosen currency code. |  |
| **Returns:** |  |  |
|  | **SystemMessages -** Collection of messages from the external system. |  |
| **Exceptions:** |  |  |
|  | No exceptions are thrown by this method. |  |

Usage example:

```csharp
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.
    }
}

```

</details>

<details>
<summary><h2>GetEligiblePromotionIds method</h2></summary>

| **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**<br><br>The target shop. |  |
|  | **ProductId** **– Mandatory**<br><br>The ID of the product for which promotions should be retrieved. |  |
|  | **TargetTime – Optional**<br><br>The time context that will be used to determine which promotions are eligible. |  |
|  | **CustomerId – Optional**<br><br>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:

```csharp
var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetEligiblePromotionIdsRequest()
{
    ProductId = "Product001",
    CustomerId = "TestCustomer"
};
var result = provider.GetEligiblePromotionIds(request);

```

</details>

<details>
<summary><h2>GetProductPromotionDescription method</h2></summary>

| **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**<br><br>The target shop. |  |
|  | **PromotionIds – Mandatory**<br><br>The IDs of the promotions to retrieve. |  |
|  | **CustomerId – Optional**<br><br>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:

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

```

</details>