Order Linesレンダリングのカスタマイズ

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

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

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

メモ

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

次のコードは、既定のレンダリング バリアント内で定義されたOrder LinesレンダリングのScribanテンプレートを示しています。製品名、バリアント情報、および配送情報はMVCモデルに渡され、レンダリング バリアントと埋め込みアイテム を使用したScribanテンプレートで使用できますo_model

{{ # Error message area }}
{{if o_model.error_message}}
<div class="error-message">
    {{ o_model.error_message }}
</div>
{{ # If there is no error, order lines will be rendered }}
{{ else }}
<div class="order-lines">
    {{ # Order lines header label }}
    <div class="order-lines-header">
        <h3 title="{{ o_model.your_products_header_tooltip }}">
            {{ sc_field i_datasource "Order Lines Header Label" }}
        </h3>
    </div>
{{ # Order lines header, contains the column titles }}
&#x3C;div class="orderlines-header">
    &#x3C;div class="orderlines-header-productdetails">
        {{ sc_field i_datasource "Product Details Label" }}
    &#x3C;/div>
    &#x3C;div class="orderlines-header-unitprice">
        {{ sc_field i_datasource "Unit Price Label" }}
    &#x3C;/div>
    &#x3C;div class="orderlines-header-quantity product-quantity-header">
        {{ sc_field i_datasource "Quantity Label" }}
    &#x3C;/div>
    &#x3C;div class="orderlines-header-total line-total-header">
        {{ sc_field i_datasource "Total Label" }}
    &#x3C;/div>
&#x3C;/div>

{{ # Order lines body, the following &#x3C;div> will render all the order lines }}
&#x3C;div class="orderlines-body">
    {{ # Loop through all the lines }}
    {{ for orderLine in o_model.lines }}
    &#x3C;div class="orderlines-item {{ if orderLine.is_free_gift }}freegift-item{{ end }}">
        &#x3C;div class="orderlines-item-details">
            {{ # The following &#x3C;div> contains the product name, variant information and delivery information }}
            &#x3C;div class="orderlines-item-productdetails">
                {{ # The free gift label is rendered if the order line IsFreeGift property is true }}
                {{ if orderLine.is_free_gift }}
                &#x3C;div class="orderlines-freegifttext">
                    &#x3C;span>{{ sc_field i_datasource "Free Gift Label" }}&#x3C;/span>
                &#x3C;/div>
                {{ end }}
                &#x3C;div class="product-image">
                    &#x3C;img src="{{ orderLine.product_master_image | sc_imagelink 110 110 }}" />
                &#x3C;/div>
                &#x3C;div class="orderlines-info">
                    &#x3C;a href="{{ orderLine.product_url }}">
                        &#x3C;h4 class="product-name">{{ orderLine.product_display_name }}&#x3C;/h4>
                    &#x3C;/a>

                    {{ # The following &#x3C;div> contains the product variant information }}
                    &#x3C;div class="product-variants">
                        {{ for property in orderLine.properties }}
                        &#x3C;div class="product-variant">
                            &#x3C;span class="variant-label">
                                {{
                                    if (object.has_key o_model.variant_labels property.key)
                                        o_model.variant_labels[property.key]
                                    else
                                        property.key
                                    end
                                }}
                            &#x3C;/span>
                            &#x3C;span class="variant-information">
                                {{ property.value }}
                            &#x3C;/span>
                        &#x3C;/div>
                        {{ end }}
                    &#x3C;/div>

                    {{ # The following &#x3C;p> contains the delivery method information }}
                    {{ if orderLine.shipping_method_name }}
                    &#x3C;p class="orderlines-delivery">
                        &#x3C;span>
                            {{ sc_field i_datasource "Order Lines Delivery Label" }}:
                        &#x3C;/span>
                        &#x3C;span class="shippingMethodName">
                            {{ orderLine.shipping_method_name }}
                        &#x3C;/span>
                    &#x3C;/p>
                    {{ end }}

                    {{ # The following &#x3C;div> contains the delivery address information }}
                    {{ if orderLine.address }}
                    &#x3C;div class="orderlines-delivery-address">
                        &#x3C;span class="address-label">{{ sc_field i_datasource "Order Lines Address Label" }}:&#x3C;/span>
                        &#x3C;ul class="lineShippingAddress">
                            &#x3C;li>
                                &#x3C;span class="lineShippingAddressLine">
                                    {{ orderLine.address.address1 }},
                                &#x3C;/span>
                                &#x3C;span class="lineShippingAddressCity">
                                    {{ orderLine.address.city }}
                                &#x3C;/span>
                            &#x3C;/li>
                            &#x3C;li>
                                &#x3C;span class="lineShippingAddressState">
                                    {{ orderLine.address.state }},
                                &#x3C;/span>
                                &#x3C;span class="lineShippingAddressZipCode">
                                    {{ orderLine.address.zip_postal_code }},
                                &#x3C;/span>
                                &#x3C;span class="lineShippingAddressCountry">
                                    {{ orderLine.address.country }}
                                &#x3C;/span>
                            &#x3C;/li>
                        &#x3C;/ul>
                    &#x3C;/div>

                    {{ # The following &#x3C;p> contains the electronic delivery email address information }}
                    {{ if orderLine.electronic_delivery_email }}
                    &#x3C;p class="orderlines-email">{{ orderLine.electronic_delivery_email }}&#x3C;/p>
                    {{ end }}
                    {{ end }}
                &#x3C;/div>
            &#x3C;/div>

            {{ # The following &#x3C;div> contains the unit price and discount offers applied }}
            {{ if !orderLine.is_free_gift }}
            &#x3C;div class="orderlines-item-price unit-price">
                &#x3C;span class="price-amount">{{ orderLine.price_text }}&#x3C;/span>
                {{ if orderLine.discount_offer_names.size > 0 }}
                &#x3C;span class="discount-details">
                    &#x3C;span>{{ sc_field i_datasource "Order Lines Discount Label" }}: &#x3C;/span>
                    &#x3C;span class="savings">{{ orderLine.discount_offer_names | array.join ", " }}&#x3C;/span>
                &#x3C;/span>
                {{ end }}
            &#x3C;/div>
            {{ end }}

            {{ # The following &#x3C;div> contains the product quantity }}
            &#x3C;div class="orderlines-item-quantity product-quantity">
                {{ orderLine.quantity_text }}
            &#x3C;/div>

            {{ # The following &#x3C;div> contains the total price and discount amount }}
            &#x3C;div class="orderlines-item-total line-total">
                &#x3C;h4 class="total-amount">{{ orderLine.total_text }}&#x3C;/h4>
                {{ # If the order line is free gift, show the original price, otherwise show the discount }}
                {{ if orderLine.is_free_gift }}
                &#x3C;span class="orderlines-freegiftlistprice">{{ orderLine.price_text }}&#x3C;/span>
                {{ else if orderLine.line_discount > 0 }}
                &#x3C;span class="savings">
                    &#x3C;span>{{ sc_field i_datasource "Order Lines Discount Label" }} &#x3C;/span>
                    &#x3C;span class="discount">{{ orderLine.line_discount_text }}&#x3C;/span>
                &#x3C;/span>
                {{ end }}
            &#x3C;/div>
        &#x3C;/div>
        {{ # Item sublines, contains the sublines for the current product }}
        {{ if orderLine.sub_lines }}
        &#x3C;div class="orderlines-item-sublines">
            {{ # Loop through all the sublines }}
            {{ for subLine in orderLine.sub_lines }}
            &#x3C;div class="orderlines-subline-item">
                {{ # Placeholder for blank space }}
                &#x3C;div class="orderlines-subline-image-space">&#x3C;/div>
                {{ # The following &#x3C;div> contains the subline product image }}
                &#x3C;div class="product-image">
                    &#x3C;a href="{{ subLine.product_url }}">
                        &#x3C;img src="{{ subLine.product_master_image | sc_imagelink 110 110 }}" />
                    &#x3C;/a>
                &#x3C;/div>
                {{ # The following &#x3C;div> contains the subline product name and variant information }}
                &#x3C;div class="orderlines-info">
                    &#x3C;a href="{{ subLine.product_url }}">
                        &#x3C;h4 class="product-name">{{ subLine.product_display_name }}&#x3C;/h4>
                    &#x3C;/a>
                    &#x3C;div class="product-variants">
                        {{ for property in subLine.properties }}
                        &#x3C;div class="product-variant">
                            &#x3C;span class="variant-label">
                                {{
                                    if (object.has_key o_model.variant_labels property.key)
                                        o_model.variant_labels[property.key]
                                    else
                                        property.key
                                    end
                                }}
                            &#x3C;/span>
                            &#x3C;span class="variant-information">
                                {{ property.value }}
                            &#x3C;/span>
                        &#x3C;/div>
                        {{ end }}
                    &#x3C;/div>
                &#x3C;/div>
                {{ # The following &#x3C;div> contains the subline product quantity }}
                &#x3C;div class="product-quantity">
                    {{ subLine.quantity_text }}
                &#x3C;/div>
                {{ # Placeholder for blank space }}
                &#x3C;div class="orderlines-subline-total-space">&#x3C;/div>
            &#x3C;/div>
            {{ end }}
        &#x3C;/div>
        {{ end }}
    &#x3C;/div>
    {{ end }}
&#x3C;/div>

</div> {{ end }}

Order Linesレンダリング モデル

Order Lines Scribanテンプレートでは、埋め込みアイテムo_modelを使用して、OrderlinesRenderingModelモデルに含まれるプロパティとオブジェクトにアクセスします。Order Linesレンダリング モデルを次の図に示します。

Diagram of the Order Lines rendering model

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