# Shopifyの明細書にメタフィールドを出力させる

**URL:** <https://community.shopify.com/t/shopify/184531>\
**Category:** 技術的なQ＆A\
**Created:** [January 18, 2023, 6:12am UTC](https://community.shopify.com/t/shopify/184531 "2023-01-18T06:12:02Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

ユーザーがShopifyの明細書（Order Printer使用）に商品のメタフィールドを出力する方法について質問。

**解決方法:**
- `line_item`オブジェクトから`item.product.metafields`でメタフィールドにアクセス可能
- 具体的なコード例が提供された:
```
{% for item in order.line_items %}
  {{ item.product.metafields.custom.metasample }}
{% endfor %}
```
- ネームスペースとキーの値は「custom.metasample」を参考に任意のものに変更可能

**結果:**
質問者は無事に表示できたことを報告し、解決済み。

<div class="post-metadata">

**Author:** ![suzuki\_3](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@suzuki\_3](https://community.shopify.com/u/suzuki_3)\
**Post date:** [January 18, 2023, 6:12am UTC](https://community.shopify.com/t/shopify/184531/1 "2023-01-18T06:12:02Z")

</div>

Shopifyの明細書に商品のメタフィールド出力させたいです。

line\_itemのobjectにはmetafieldsのpropertiesがなかったのですが、可能でしょうか？

（Order Printerは使用しません。）

どなたかアドバイスいただけると幸いです。

---

<div class="post-metadata">

**Author:** ![Qcoltd](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/qcoltd/32/900_2.png) [@Qcoltd](https://community.shopify.com/u/Qcoltd)\
**Post date:** [January 18, 2023, 9:51am UTC](https://community.shopify.com/t/shopify/184531/2 "2023-01-18T09:51:07Z")

</div>

ご質問いただいていますShopifyの明細書では、

下記の方法でメタフィールドを取得し表示することが可能です。

```markup
{% for item in order.line_items %}
  {{ item.product.metafields.custom.metasample }}
{% endfor %}

```

メタフィールドのネームスペースとキーの値は「custom.metasample」としていますので、

任意のものに変更いただければと思います。

ご参考まで。

(キュー小坂)

---

<div class="post-metadata">

**Author:** ![suzuki\_3](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@suzuki\_3](https://community.shopify.com/u/suzuki_3)\
**Post date:** [January 18, 2023, 1:11pm UTC](https://community.shopify.com/t/shopify/184531/3 "2023-01-18T13:11:13Z")

</div>

表示されました、勉強不足で申し訳ございません。

ありがとうございました。
