> ## Documentation Index
> Fetch the complete documentation index at: https://foliant-help.iforiti.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 注文属性とラインアイテムのプロパティ

> ギフトメッセージ、配送日、刻印テキストなど、お客様がチェックアウト時や商品ページで入力したカスタムフィールドを印刷します。

多くのストアでは、お客様から追加の情報を受け取っています。チェックアウト時の配送日やギフトメッセージ(注文属性。カート属性やメモ属性とも呼ばれます)や、商品ページでの刻印テキストやモノグラム(ラインアイテムのプロパティ)などです。Shopify はこれらを注文と一緒に保存し、テンプレートで印刷できます。

## 注文属性

`attributes` には注文のカスタムフィールドが入っています。各フィールドは名前と値の組です。

すべてを印刷するには、次のようにします。

```liquid theme={null}
{% for attribute in attributes %}
  <p><strong>{{ attribute.first | escape }}:</strong> {{ attribute.last | escape }}</p>
{% endfor %}
```

1 つだけを印刷するには、注文での表記どおりに名前を指定します。

```liquid theme={null}
{% if attributes['Gift message'] != blank %}
  <p>{{ attributes['Gift message'] | escape }}</p>
{% endif %}
```

## ラインアイテムのプロパティ

各ラインアイテムの `properties` には、そのアイテムのカスタムフィールドが入っています。ラインアイテムのループ内で印刷します。

```liquid theme={null}
{% for line_item in line_items %}
  {{ line_item.title }}
  {% for property in line_item.properties %}
    {% unless property.last == blank %}
      <br>{{ property.first | escape }}: {{ property.last | escape }}
    {% endunless %}
  {% endfor %}
{% endfor %}
```

`property.first` はフィールドの名前、`property.last` はその値です。

名前がアンダースコアで始まるプロパティ(`_bundle_id` など)は、非表示にすることを想定したものです。これらを除外するには、次のようにします。

```liquid theme={null}
{% assign first_letter = property.first | slice: 0 %}
{% unless first_letter == '_' or property.last == blank %}
  {{ property.first | escape }}: {{ property.last | escape }}
{% endunless %}
```

## ビジュアルエディターの場合

* **商品テーブル**: **行** の下にある **ラインアイテムのプロパティ(刻印、ギフトメッセージなど)** にチェックを入れると、各アイテムのタイトルの下にプロパティが印刷されます。名前がアンダースコアで始まるプロパティと、空のプロパティは除外されます。
* 注文属性: **カスタム Liquid** ブロックに上記のループを入れて使用します。

## 補足

* お客様が入力した内容には必ず `| escape` を付けてください。入力内容がそのままテキストとして印刷されます。
* 注文属性の名前は大文字と小文字が区別されます。`attributes['gift message']` と `attributes['Gift message']` は別のものです。
* 属性ではなくメタフィールドに保存されたデータは、印刷方法が異なります。[テンプレートでのメタフィールド](https://foliant-help.iforiti.com/jp/template-editor/metafields.md)をご覧ください。
* Bold Product Options や Infinite Options での選択内容もラインアイテムのプロパティです。有料アドオンはアイテムの下に印刷できます。詳しくは [商品オプションアプリ(Bold、Infinite Options)](https://foliant-help.iforiti.com/jp/templates/product-options-apps.md) をご覧ください。

## 関連記事

* [テンプレートでのラインアイテム](https://foliant-help.iforiti.com/jp/template-editor/liquid-line-items.md)
* [テンプレートでのメタフィールド](https://foliant-help.iforiti.com/jp/template-editor/metafields.md)
* [Liquid での条件付きコンテンツ](https://foliant-help.iforiti.com/jp/template-editor/liquid-conditional-content.md)
* [ブロックリファレンス](https://foliant-help.iforiti.com/jp/template-editor/block-catalogue.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.