---
title: "価格設定サービス方法"
slug: "pricing-service-methods"
abstract: ""
---
# 価格設定サービス方法

サービスプロバイダーは、Connectパイプラインとのやり取りを容易にするために設計されたラッパーオブジェクトです。プロバイダーはConnectパイプラインを呼び出す以外のロジックを実装しません。すべてのビジネスロジックはパイプラインプロセッサ内で実装されています。

プライシングサービスプロバイダーには、価格データとやり取りするための以下の手法が含まれています。

## GetProductPricesメソッド

-   **説明:**特定の商品の価格を取得。
-   **使用方法:**特定の製品の価格が必要な時にSitecoreに呼ばれます。
-   **署名:**GetProductPricesResult GetProductPrices(GetProductPricesRequest request)
-   **パラメータ:**
-   :

request.ProductId -

-   :

Request.UserId -

-   :

Request.CurrencyCode -

-   :

Request.Location -

-   :

Request.Quantity -

-   :

Request.DateTime -

-   :

Request.ShopName -

-   :

Request.PriceTypeIds -

-   **返品:**
-   :

result.Prices -

-   :

result.ExternalSystem Messages -

-   **例外:**
-   :

使用例:

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メソッド

-   **説明:**特定の製品のまとめ価格を取得。
-   **使用:**: Sitecoreが特定の商品の割引価格が必要なときに呼び出されます。
-   **署名:**GetProductBreakPricesResult GetProductBreakPrices(GetProductBreakPricesRequest request)
-   **パラメータ:**
-   :

request.ProductId -

-   :

Request.UserId -

-   :

Request.CurrencyCode -

-   :

Request.Location -

-   :

Request.Quantity -

-   :

Request.DateTime -

-   :

Request.ShopName -

-   **返品:**
-   :

result.Prices -

-   :

result.ExternalSystem Messages -

-   **例外:**
-   :

使用例:

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メソッド

-   **説明:**特定のカートの価格を表示します。
-   **使用方法:**: Sitecoreが特定のカートリッジの価格が必要なときに呼び出します。
-   **署名:**GetCartPriceResult GetCartPrice(GetCartPriceRequest request)
-   **パラメータ:**
-   :

request.Cart -

-   :

request.UserId -

-   :

Request.CurrencyCode -

-   :

Request.Location -

-   :

Request.ShopName -

-   :

Request.DateTime -

-   **返品:**
-   :

result.Cart -

-   :

result.ExternalSystem Messages -

-   **例外:**
-   :

使用例:

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メソッド

**説明:**

ECSでサポートされている通貨のリストを入手します。

**使用方法:**

Sitecoreが対応通貨のリストを必要とするときに呼び出します。

**署名:**

GetSupportedCurrenciesResult GetSupportedCurrencies(NotNull GetSupportedCurrenciesRequest request)

**パラメータ:**

**ショップネーム – 必須**  
  
店の名前だ。

**返品:**

**IReadOnlyCollection** – サポートされているすべての通貨コードの一覧。

**SystemMessages -** 外部システムからのメッセージの収集。

**例外:**

この方法では例外は一切ありません。

使用例:

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メソッド

**説明:**

通貨**選択ページイベントを上げます****。**

**使用方法:**

SitecoreがCurrency Chosenイベントを開催する必要があるときに呼びかけられます。

**署名:**

ServiceProviderResult CurrencyChosen(CurrencyChosenRequest request)

**パラメータ:**

**ショップネーム – 必須**  
  
店の名前だ。

**ChosenCurrency** **– 必須**  
  
選ばれた通貨コード。

**返品:**

**SystemMessages -** 外部システムからのメッセージの収集。

**例外:**

この方法では例外は一切ありません。

使用例:

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メソッド

**説明:**

**商品に適用可能なプロモーションのIDを取得し** ます。

**使用方法:**

例えば、商品詳細ページで適用可能なプロモーションIDを取得するために呼び出されます。

**署名:**

GetEligiblePromotionIdsResult GetEligiblePromotionIds( GetEligiblePromotionIdsRequest request)

**パラメータ:**

**ショップ** **– 必須**  
  
ターゲットショップ。

**ProductId(製品名)****– 必須**  
  
プロモーションを取得するべき商品のID。

**ターゲットタイム – オプション**  
  
どのプロモーションが対象になるかを判断するために使われる時間の文脈。

**CustomerID – オプション**  
  
プロモーションが取得されている顧客のID。

**返品:**

**PromotionIds -** 製品に該当するプロモーションのIDを含むコレクション。

**SystemMessages -** 外部システムからのメッセージの収集。

**例外:**

この方法では例外は一切ありません。

使用例:

var provider = (PricingServiceProvider)Factory.CreateObject("pricingServiceProvider", true);
var request = new GetEligiblePromotionIdsRequest()
{
 ProductId = "Product001",
 CustomerId = "TestCustomer"
};
var result = provider.GetEligiblePromotionIds(request);
## GetProductPromotionDescriptionメソッド

**説明:**

商品のプロモーション一覧の説明を取得します。

**使用方法:**

サイトで表示するプロモーションのリストの説明を取りに来た。

**署名:**

GetProductPromotionDescriptionResult GetProductPromotionDescription(GetProductPromotionDescriptionRequest request)

**パラメータ:**

**ショップ – 必須**  
  
ターゲットショップ。

**PromotionIds – 必須**  
  
回収すべき昇進のIDです。

**CustomerID – オプション**  
  
プロモーションが取得されている顧客のID。

**返品:**

**プロモーション -** リクエストされたプロモーションを含むコレクション。

**SystemMessages -** 外部システムからのメッセージの収集。

**例外:**

この方法では例外は一切ありません。

使用例:

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