オーダーラインレンダリングのカスタマイズ

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

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

Order LinesレンダリングにはScribanテンプレートというレンダリングバリアントが含まれています。Order Linesレンダリングには独自のデフォルトレンダリングバリアントrootとデフォルトレンダリングバリアント(/sitecore/Content///Presentation/Rendering Variants/Order Lines)があり、マークアップを生成するためにScribanテンプレートを使用します。Scribanテンプレートを変更することは可能ですが、ソフトウェアのアップグレード時にカスタマイズが上書きされないように、新しいカスタムレンダリングバリアントを作成するのが最善です。レンダリングのラベルを変更することも可能です。

!note The Order Lines - 廃止されたレンダリングは既存サイトのみで利用可能で、レンダリングバリアントのScribanテンプレートではなくMVCビューに基づいています。

以下のコードは、デフォルトのレンダリングバリアント内で定義されたOrder LinesレンダリングのScribanテンプレートを示しています。製品名、バリアント情報、納品情報はMVCモデルに渡され、レンダリングバリアントや埋め込みアイテムo_model(/xp/en/developers/sxa/100/sitecore-experience-accelerator/en/the-embedded-functions-for-the-scriban-template.html)を用いるScribanテンプレートで利用可能です。

{{ # Error message area }} {{if o_model.error_message}}

{{ o\_model.error\_message }}
{{ # If there is no error, order lines will be rendered }} {{ else }}
{{ # Order lines header label }}

{{ sc\_field i\_datasource "Order Lines Header Label" }}

{{ # Order lines header, contains the column titles }}

{{ sc\_field i\_datasource "Product Details Label" }}
{{ sc\_field i\_datasource "Unit Price Label" }}
{{ sc\_field i\_datasource "Quantity Label" }}
{{ sc\_field i\_datasource "Total Label" }}

{{ # Order lines body, the following

will render all the order lines }}

{{ # Loop through all the lines }} {{ for orderLine in o\_model.lines }}
{{ # The following
contains the product name, variant information and delivery information }}
{{ # The free gift label is rendered if the order line IsFreeGift property is true }} {{ if orderLine.is\_free\_gift }}
{{ sc\_field i\_datasource "Free Gift Label" }}
{{ end }}

{{ orderLine.product\_display\_name }}

{{ # The following

contains the product variant information }}

{{ for property in orderLine.properties }}
{{ if (object.has\_key o\_model.variant\_labels property.key) o\_model.variant\_labelsproperty.key else property.key end }} {{ property.value }}
{{ end }}

{{ # The following

contains the delivery method information }} {{ if orderLine.shipping_method_name }}

{{ sc\_field i\_datasource "Order Lines Delivery Label" }}: {{ orderLine.shipping\_method\_name }}

{{ end }}

{{ # The following

contains the delivery address information }} {{ if orderLine.address }}

{{ sc\_field i\_datasource "Order Lines Address Label" }}:
  • {{ orderLine.address.address1 }}, {{ orderLine.address.city }}
  • {{ orderLine.address.state }}, {{ orderLine.address.zip\_postal\_code }}, {{ orderLine.address.country }}

{{ # The following

contains the electronic delivery email address information }} {{ if orderLine.electronic_delivery_email }}

{{ orderLine.electronic\_delivery\_email }}

{{ end }} {{ end }}

{{ # The following

contains the unit price and discount offers applied }} {{ if !orderLine.is_free_gift }}

{{ orderLine.price\_text }} {{ if orderLine.discount\_offer\_names.size > 0 }} {{ sc\_field i\_datasource "Order Lines Discount Label" }}: {{ orderLine.discount\_offer\_names | array.join ", " }} {{ end }}
{{ end }}

{{ # The following

contains the product quantity }}

{{ orderLine.quantity\_text }}

{{ # The following

contains the total price and discount amount }}

{{ orderLine.total\_text }}

{{ # If the order line is free gift, show the original price, otherwise show the discount }} {{ if orderLine.is\_free\_gift }} {{ orderLine.price\_text }} {{ else if orderLine.line\_discount > 0 }} {{ sc\_field i\_datasource "Order Lines Discount Label" }} {{ orderLine.line\_discount\_text }} {{ end }}
{{ # Item sublines, contains the sublines for the current product }} {{ if orderLine.sub\_lines }}
{{ # Loop through all the sublines }} {{ for subLine in orderLine.sub\_lines }}
{{ # Placeholder for blank space }}
{{ # The following
contains the subline product image }} {{ # The following
contains the subline product name and variant information }}

{{ subLine.product\_display\_name }}

{{ for property in subLine.properties }}
{{ if (object.has\_key o\_model.variant\_labels property.key) o\_model.variant\_labelsproperty.key else property.key end }} {{ property.value }}
{{ end }}
{{ # The following
contains the subline product quantity }}
{{ subLine.quantity\_text }}
{{ # Placeholder for blank space }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

順序線レンダリングモデル

Order Lines Scribanテンプレートでは、埋め込みアイテムo_modelを通じてOrderlinesRenderingModelモデルに含まれるプロパティやオブジェクトにアクセスできます。Order Linesレンダリングモデルは以下の図に示されています。

Diagram of the Order Lines rendering model
この記事を改善するための提案がある場合は、 お知らせください!