---
title: "製品価格レンダリングのカスタマイズ"
slug: "customizing-the-product-price-rendering"
abstract: "Product PriceレンダリングScribanテンプレートの概要。"
---
# 製品価格レンダリングのカスタマイズ

Product Priceレンダリングには[Scriban](https://doc.sitecore.com/xp/ja/developers/100/sitecore-experience-commerce/working-with-scriban-templates.html "Working with Scriban templates")テンプレートというレンダリングバリアントが含まれています。Product Priceレンダリングには独自のデフォルトレンダリング [バリアントrootとデフォルトレンダリングバリアント](https://doc.sitecore.com/xp/en/users/93/sitecore-experience-commerce/en/using-rendering-variants-to-display-product-information.html) (*/sitecore/Content///Presentation/Rendering Variants/Product Price*)があり、マークアップを生成するためにScribanテンプレートを使用します。Scribanテンプレートを変更することは可能ですが、ソフトウェアアップグレード時にカスタマイズが上書きされないように、新しいカスタムレンダリングバリアントを作成するのが最善です。レンダリングの [ラベルを変更する](https://doc.sitecore.com/xp/ja/developers/100/sitecore-experience-commerce/modify-a-label-for-a-rendering-that-uses-a-scriban-template.html "Modify a label for a rendering that uses a Scriban template") ことも可能です。

> !note The Product Price - 非推奨)レンダリングは既存サイトのみで利用可能で、レンダリングバリアントのScribanテンプレートではなくMVCビューに基づいています。

以下のコードは、デフォルトのレンダリングバリアント内で定義されたProduct PriceレンダリングのScribanテンプレートを示しています。調整された価格とリスト価格はMVCモデルに渡され、レンダリングバリアントや埋め込みアイテムo\_model(the-embedded-commerce-items-and-objects-for-scriban-templates.md "The embedded Commerce items and objects for Scriban templates")を用いるScribanテンプレートで利用可能です。

{{ # The <div> element to show the error message. }}
{{ if o\_model.error\_message}}
 <div class="error-message">
 {{o\_model.error\_message}}
 </div>
{{else
 if i\_datasource
 if o\_model.is\_on\_sale
 percentLead = i\_datasource.SavingsLeadText.raw
 savingsMessage = percentLead + ' ' + o\_model.savings\_percentage + '%'
 }}
 <input type="hidden" value="{{savingsMessage}}" id="productprice-savingsmessage" />
 {{end}}
 <div class="price-info" productid="{{o\_model.product\_id}}" listprice="{{o\_model.formatted\_list\_price}}" adjustedprice="{{o\_model.formatted\_adjusted\_price}}" isonsale="{{o\_model.is\_on\_sale}}">
 <div class="price-now-before">
 <div class="price-with-savings">
 <h3>
 <span data-bind="text: priceNow"></span>
 <span data-bind="text: savingsMessage"></span>
 </h3>
 </div>
 <div class="price-before">
 <h3>
 <span data-bind="text: priceBefore"></span>
 </h3>
 </div>
 </div>
 <div class="price-only">
 <h3>
 <span data-bind="text: priceNow"></span>
 </h3>
 </div>
 </div>
{{else
 if o\_pagemode.is\_experience\_editor\_editing
 'No Data source has been selected'
end
end
end}}

## 製品価格レンダリングモデル

Product Price Scribanテンプレートでは、以下の図に示すように埋め込まれたアイテムo\_modelを通じて、ProductPriceRenderingModelモデルに含まれるプロパティやオブジェクトにアクセスできます。

![Diagram of the Product Price rendering model](https://doc.sitecore.com/api/markdown-image/xp/ja/developers/100/sitecore-experience-commerce/images/ProductPriceRenderingModel.png)