> ## 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.

# テンプレートでの明細行

> Liquidで注文の明細行をループし、商品名、数量、価格、SKU、画像、重量、プロパティを印刷します。

注文の商品は `line_items` に入っています。印刷するには、このリストをループします。`{% for line_item in line_items %}` と `{% endfor %}` の間の内容が商品ごとに1回繰り返され、`line_item` が現在の商品を表します。明細行のフィールドはループ内でのみ機能します。

## 基本的な商品テーブル

```liquid theme={null}
<table>
  {% for line_item in line_items %}
    <tr>
      <td>{{ line_item.title }}</td>
      <td>{{ line_item.sku }}</td>
      <td>{{ line_item.quantity }}</td>
      <td>{{ line_item.price | money }}</td>
      <td>{{ line_item.line_price | money }}</td>
    </tr>
  {% endfor %}
</table>
```

## 明細行のフィールド

| 変数 | 印刷される内容 |
| - | - |
| `line_item.title` | 商品のタイトル(商品とバリエーション) |
| `line_item.name` | 商品の名前 |
| `line_item.product_title` | 商品のタイトル |
| `line_item.variant_title` | バリエーションのタイトル(例:「Blue / Large」) |
| `line_item.quantity` | 注文数量(返金済みの商品を含む) |
| `line_item.fulfillable_quantity` | まだフルフィルメントが必要な数量 |
| `line_item.refunded_quantity` | 返金された数量 |
| `line_item.sku` | SKU |
| `line_item.vendor` | 販売元 |
| `line_item.price` | 明細行の割引適用後の単価(セント単位) |
| `line_item.original_price` | 割引前の単価(セント単位) |
| `line_item.line_price` | 明細行の合計:単価 × 数量、明細行の割引適用後(セント単位) |
| `line_item.total_discount` | 明細行の割引額(セント単位) |
| `line_item.discount_per_item` | 商品1点あたりの割引額(セント単位) |
| `line_item.total_tax` | 明細行の税額(セント単位) |
| `line_item.cost` | 商品の原価、発注書用(セント単位) |
| `line_item.tax_lines` | 明細行の税金:ループして `title`、`rate`、`price` を取得します |
| `line_item.discount_allocations` | 明細行に適用された割引:ループして `amount` を取得します |
| `line_item.properties` | 明細行のプロパティ。[注文属性と明細行のプロパティ](https://foliant-help.iforiti.com/jp/template-editor/liquid-custom-fields.md)をご覧ください。 |
| `line_item.hs_tariff_code` | HS関税コード |
| `line_item.country_of_origin` | 原産国 |
| `line_item.weight` | 商品1点の重量(商品自体の単位) |
| `line_item.grams` | 商品1点の重量(グラム単位)。`{{ line_item.grams \| weight_with_unit }}` で単位が付きます |
| `line_item.total_weight` | 明細行の重量(商品 × 数量) |
| `line_item.image` | 商品の画像。`{{ line_item.image \| img_url: 'thumb' \| img_tag }}` で印刷されます |
| `line_item.requires_shipping` | 商品の配送が必要かどうか |
| `line_item.gift_card` | 商品がギフトカードかどうか |
| `line_item.product` | 商品(`title`、`type`、`vendor`、`tags`、`handle`…) |
| `line_item.variant` | バリエーション(`title`、`sku`、`barcode`、`option1`、`inventory_quantity`…) |

## よく使うパターン

バリエーションのタイトルがある場合のみ、商品名の下に印刷します:

```liquid theme={null}
{{ line_item.product_title }}
{% if line_item.variant_title != blank %}<br>{{ line_item.variant_title }}{% endif %}
```

納品書で、全額返金された商品を除外します:

```liquid theme={null}
{% for line_item in line_items %}
  {% if line_item.quantity > line_item.refunded_quantity %}
    {{ line_item.title }} × {{ line_item.quantity | minus: line_item.refunded_quantity }}
  {% endif %}
{% endfor %}
```

各SKUのバーコードを表示します:

```liquid theme={null}
{{ line_item.sku | barcode }}
```

## 配送ごとに1つの書類

テンプレートが配送ごとに1つの書類を印刷する場合(テンプレートの設定ページの **分割配送**)、`document_fulfillment` は印刷中の配送を表します。その配送に含まれる商品だけを一覧表示するには、次のようにします:

```liquid theme={null}
{% if document_fulfillment %}
  {% assign line_items = document_fulfillment.line_items %}
{% endif %}
```

## 補足

* 価格はセント単位です。必ず通貨フィルターを使って印刷してください。[テンプレートでの金額と通貨](https://foliant-help.iforiti.com/jp/template-editor/liquid-money-and-currency.md)をご覧ください。
* 商品画像は、`img_url` で指定したサイズで印刷されます。例:`'thumb'`、`'small'`、`'medium'`、`'120x120'`。
* 商品とバリエーションのメタフィールドは、`line_item.product.metafields` と `line_item.variant.metafields` にあります。[テンプレートでのメタフィールド](https://foliant-help.iforiti.com/jp/template-editor/metafields.md)をご覧ください。
* ループ変数の名前は自由に決められますが、`line_item` にするとリファレンスやスターターテンプレートと一致します。
* Bold Product Options と Infinite Options の注文には `line_item.options`, `line_item.option_addon`, `line_item.option_addons` とアドオン込みの価格が追加されるため、有料アドオンを該当アイテムの下に印刷できます。詳しくは [商品オプションアプリ(Bold、Infinite Options)](https://foliant-help.iforiti.com/jp/templates/product-options-apps.md) をご覧ください。

## 関連記事

* [注文オブジェクトとよく使う変数](https://foliant-help.iforiti.com/jp/template-editor/liquid-order-variables.md)
* [テンプレートでの金額と通貨](https://foliant-help.iforiti.com/jp/template-editor/liquid-money-and-currency.md)
* [注文属性と明細行のプロパティ](https://foliant-help.iforiti.com/jp/template-editor/liquid-custom-fields.md)
* [テンプレートでのメタフィールド](https://foliant-help.iforiti.com/jp/template-editor/metafields.md)
* [商品オプションアプリ(Bold、Infinite Options)](https://foliant-help.iforiti.com/jp/templates/product-options-apps.md)


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