Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,6 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto-pay orders from customers with a certain tag](./auto-pay-orders-from-customers-with-a-certain-tag)
* [Auto-pay orders having a certain tag](./auto-pay-orders-having-a-certain-tag)
* [Auto-publish products tagged with the current day](./auto-publish-products-tagged-with-the-current-day)
* [Auto-tag a customer's first order](./auto-tag-a-customers-first-order)
* [Auto-tag customers when another tag is added](./auto-tag-customers-when-another-tag-is-added)
* [Auto-tag customers when their order is tagged](./auto-tag-customers-when-their-order-is-tagged)
* [Auto-tag orders that do not have a certain tag](./auto-tag-orders-that-do-not-have-a-certain-tag)
Expand Down
2 changes: 1 addition & 1 deletion docs/auto-tag-a-customers-first-order/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Auto-tag a customer's first order

Tags: Auto-Tag, Customers, Orders, Tag
Tags: Auto-Tag, Customers, Orders

Watches for incoming orders that are the very first order on file for the related customer, and adds the tag of your choice.

Expand Down
5 changes: 5 additions & 0 deletions docs/auto-tag-a-customers-first-order/script.liquid
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{% unless order.customer or event.preview %}
{% log "This order does not have a customer." %}
{% break %}
{% endunless %}

{% capture query %}
query {
customer(id: {{ order.customer.admin_graphql_api_id | json }}) {
Expand Down
5 changes: 2 additions & 3 deletions tasks/auto-tag-a-customers-first-order.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"preview_event_definitions": [],
"script": "{% capture query %}\n query {\n customer(id: {{ order.customer.admin_graphql_api_id | json }}) {\n numberOfOrders\n }\n }\n{% endcapture %}\n\n{% assign result = query | shopify %}\n\n{% if event.preview %}\n {% capture result_json %}\n {\n \"data\": {\n \"customer\": {\n \"numberOfOrders\": \"1\"\n }\n }\n }\n {% endcapture %}\n\n {% assign result = result_json | parse_json %}\n{% endif %}\n\n{% if result.data.customer.numberOfOrders == \"1\" %}\n {% action \"shopify\" %}\n mutation {\n tagsAdd(\n id: {{ order.admin_graphql_api_id | json }}\n tags: {{ options.order_tag_to_add__required | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n{% else %}\n {% log numberOfOrders: result.data.customer.numberOfOrders %}\n{% endif %}",
"script": "{% unless order.customer or event.preview %}\n {% log \"This order does not have a customer.\" %}\n {% break %}\n{% endunless %}\n\n{% capture query %}\n query {\n customer(id: {{ order.customer.admin_graphql_api_id | json }}) {\n numberOfOrders\n }\n }\n{% endcapture %}\n\n{% assign result = query | shopify %}\n\n{% if event.preview %}\n {% capture result_json %}\n {\n \"data\": {\n \"customer\": {\n \"numberOfOrders\": \"1\"\n }\n }\n }\n {% endcapture %}\n\n {% assign result = result_json | parse_json %}\n{% endif %}\n\n{% if result.data.customer.numberOfOrders == \"1\" %}\n {% action \"shopify\" %}\n mutation {\n tagsAdd(\n id: {{ order.admin_graphql_api_id | json }}\n tags: {{ options.order_tag_to_add__required | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n{% else %}\n {% log numberOfOrders: result.data.customer.numberOfOrders %}\n{% endif %}",
"subscriptions": [
"shopify/orders/create"
],
"subscriptions_template": "shopify/orders/create",
"tags": [
"Auto-Tag",
"Customers",
"Orders",
"Tag"
"Orders"
]
}