# 通知メールのカスタマイズについて

**URL:** <https://community.shopify.com/t/topic/135077>\
**Category:** 総合的なディスカッション\
**Created:** [July 14, 2022, 1:12am UTC](https://community.shopify.com/t/topic/135077 "2022-07-14T01:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

Shopifyの通知メールに、Product Options Variant Optionアプリで追加したオプション名と選択項目を表示したい。 

- 対応方法: Line Item Property（商品ごとのカスタム属性）を用い、通知メールテンプレート内の「subtotal_line_items」のforループにコードを追記。 
- 追加コードの要旨: line.propertiesの有無を判定し、空でないプロパティについて「p.first（項目名）: p.last（選択値）」を出力。 
- 技術的ポイント: 編集箇所は通知メールのforループ内部。Line Item Propertyはアプリが付与するオプション情報の受け皿。 
- 参考情報: デモストアURL、Shopifyブログ記事、コミュニティ投稿のコードを簡略化して利用（当初は未検証の注記あり）。 
- 最新の結果: コードを追加したところ、通知メールにアプリ側オプションが表示されるようになり目的を達成。 
- 状態: 解決済み。未決事項や追加の課題はなし。 
- 注意: コードスニペットの編集が中心となるため、テンプレート構造（forループ）を正しく特定することが重要。

<div class="post-metadata">

**Author:** ![ponuco](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@ponuco](https://community.shopify.com/u/ponuco)\
**Post date:** [July 14, 2022, 1:12am UTC](https://community.shopify.com/t/topic/135077/1 "2022-07-14T01:12:57Z")

</div>

下記のアプリ（Product Options Variant Option）を使って商品にオプションを追加したのですが、

通知メールにもオプション名と選んだ項目が表示されるようにしたいです。

表示させることは可能でしょうか？

[https://apps.shopify.com/product-options-pro?locale=ja&st\_campaign=about-app&st\_source=admin&utm\_campaign=installed&utm\_content=contextual&utm\_medium=shopify&utm\_source=admin](https://apps.shopify.com/product-options-pro?locale=ja&st_campaign=about-app&st_source=admin&utm_campaign=installed&utm_content=contextual&utm_medium=shopify&utm_source=admin)

---

<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:** [July 14, 2022, 10:36am UTC](https://community.shopify.com/t/topic/135077/2 "2022-07-14T10:36:46Z")

</div>

可能と考えています。

アプリのデモストアを見ながらの回答になります。

[https://globo1.myshopify.com/products/all-options](https://globo1.myshopify.com/products/all-options)

どうやら、言及されているアプリは、

こちらのブログでも紹介されている、Line Item Propertyを利用しているようですね。

[https://www.shopify.com/jp/blog/partner-shopify-theme-customize-cart-attributes-line-item-property-customer-note](https://www.shopify.com/jp/blog/partner-shopify-theme-customize-cart-attributes-line-item-property-customer-note)

Line Item Propertyを通知メールで出力するには、

通知メール内の下記の箇所にコードを追加します。

```markup
{% for line in subtotal_line_items %}
{% comment %} このforループの中にコードを記載します。通知メールの中に既にこのforループがあるはずですのでお探しください。 {% endcomment %}
{% endfor %}

```

追加するコードは下記です。

```markup
{% assign property_size = line.properties | size %}
{% if property_size > 0 %}
{% for p in line.properties %}
  {% unless p.last == blank %}
    {{ p.first }}: {{ p.last }}

  {% endunless %}
{% endfor %}
{% endif %}

```

こちらのコードは、下記のコミュニティへの投稿から拝借して、

今回は不要と思われる箇所を削除したものです。

※動作確認はしておりません。

[https://community.shopify.com/topic/1626066](https://community.shopify.com/topic/1626066)

ご参考まで。

(キュー田辺)

---

<div class="post-metadata">

**Author:** ![ponuco](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@ponuco](https://community.shopify.com/u/ponuco)\
**Post date:** [July 15, 2022, 5:42am UTC](https://community.shopify.com/t/topic/135077/3 "2022-07-15T05:42:49Z")

</div>

ご回答ありがとうございます。

こちらのコードを追加したらアプリ側のオプション部分も表示されるようになりました！

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