商品価格レンダリングのカスタマイズ

Version: 10.1
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

Product Priceレンダリングには、Scribanテンプレートの形式のレンダリング バリアントが含まれています。Product Priceレンダリングには、独自のデフォルト レンダリングバリアントルートと、マークアップの生成にScribanテンプレートを使用するデフォルトのレンダリングバリアント(/sitecore/Content/<tenant>/<site>/Presentation/Rendering Variants/Product Price)があります。Scribanテンプレートは変更できますが、この場合は、ソフトウェアのアップグレード中にカスタマイズが上書きされないように、新しいカスタム レンダリング バリアントを作成することをお勧めします。レンダリングの ラベルを変更する こともできます。

メモ

The Product Price - deprecated) レンダリングは既存のサイトでのみ使用でき、レンダリングバリアントのScribanテンプレートではなくMVCビューに基づいています。

次のコードは、既定のレンダリング バリアント内で定義されたProduct PriceレンダリングのScribanテンプレートを示しています。調整された価格とリスト価格はMVCモデルに渡され、レンダリング バリアントと埋め込みアイテム ( o_modelを使用したScribanテンプレート) で使用できます。

RequestResponse
{{ # 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

何かフィードバックはありますか?

この記事を改善するための提案がある場合は、