# 【ShopifyFlow】顧客メタフィールドの値を顧客タグに反映

**URL:** <https://community.shopify.com/t/shopifyflow/338891>\
**Category:** Shopify アプリ\
**Created:** [July 12, 2024, 7:04am UTC](https://community.shopify.com/t/shopifyflow/338891 "2024-07-12T07:04:37Z")\
**Posts on this page:** 3\
**Page:** 1

## AI-generated summary

Shopify Flowを使用して、注文時に顧客メタフィールドの値を顧客タグに自動反映させる方法についての質問と解決。

**実現したい機能:**
- 注文発生時に特定の顧客メタフィールド（例：customer.metafields.rank.info）の値を取得
- その値の末尾に「_tag」を付けて新規顧客タグとして追加（例：値が「GOLD」なら「GOLD_tag」）
- 既存の「_tag」を含む顧客タグは削除

**提案された解決策:**
Jizo_Inagakiから、Order createトリガー、Condition設定、Remove/Add customer tagsアクションを組み合わせる方法が提案されました。

**最終的な解決:**
質問者は試行錯誤の結果、以下のフローで解決:
1. Order createトリガー
2. Remove customer tags（Liquidコードでメタフィールド値とマッチするタグを削除）
3. Add customer tags（「_tag」を含むタグを追加）

Liquidテンプレートを活用したコードスニペットが共有され、問題は解決済み。

<div class="post-metadata">

**Author:** ![mokudai](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mokudai](https://community.shopify.com/u/mokudai)\
**Post date:** [July 12, 2024, 7:04am UTC](https://community.shopify.com/t/shopifyflow/338891/1 "2024-07-12T07:04:37Z")

</div>

Shopify Flow以下を実現したいのですが可能でしょうか？

ご教示いただければ幸いです。

* * *

注文があったときに

注文した顧客の顧客タグに

既に『\_tag』を含んだ顧客タグがあった場合はそのタグを削除。

その上で、特定の顧客メタフィールド（例：customer.metafields.rank.info）の値を

値の末尾に『\_tag』と付けた状態で、新規顧客タグとして入れる。

例：メタフィールドの値が『GOLD』だったとき  
GOLD\_tagという顧客タグが入る。

---

<div class="post-metadata">

**Author:** ![Jizo\_Inagaki](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/jizo_inagaki/32/149480_2.png) [@Jizo\_Inagaki](https://community.shopify.com/u/Jizo_Inagaki)\
**Post date:** [July 17, 2024, 6:58am UTC](https://community.shopify.com/t/shopifyflow/338891/2 "2024-07-17T06:58:50Z")

</div>

試作していませんが以下のようにすれば対応できるのではと思います。

1. Order create トリガー
2. Condition で order \> customer \> metafileds \> 値(GOLD)を入力
3. Remove customer tags
4. Add customer tags

Condition に関しては以下などの情報を探して参照ください。

[https://help.shopify.com/ja/manual/shopify-flow/reference/conditions](https://help.shopify.com/ja/manual/shopify-flow/reference/conditions)

[https://community.shopify.com/post/1713926](https://community.shopify.com/post/1713926)

(上記はCusotmerに読み替え可能です)

以上ですが、よくわからない場合はShopifyサポートに相談したり、エキスパートやパートナーに依頼されることをお勧めします。

---

<div class="post-metadata">

**Author:** ![mokudai](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mokudai](https://community.shopify.com/u/mokudai)\
**Post date:** [July 18, 2024, 4:38am UTC](https://community.shopify.com/t/shopifyflow/338891/3 "2024-07-18T04:38:21Z")

</div>

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

すみません…質問後も試行錯誤していた結果下記の方法で解決いたしました。

いただいたCondition の記事につきましては別のFlowを組む際の参考にさせていただきます。

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

* * *

●Order create トリガー  
●Remove customer tags  
{% for tag in order.customer.tags %} {% if tag contains ‘\_tag’ %} {{tag}} {% endif %} {% endfor %}

●Add customer tags  
{% for metafields\_item in order.customer.metafields %} {% if metafields\_item.key == ‘info’ %} {{metafields\_item.value}}\_tag {% endif %} {% endfor %}
