-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch task that had an email address harcoded as an option (#266)
- Loading branch information
1 parent
88611fd
commit e214482
Showing
2 changed files
with
4 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ Use this task to receive an immediate email alert, whenever a variant's total in | |
"must_be_published_to_publication_id": "", | ||
"email_subject__required": "\"VARIANT_TITLE\" has hit 0 inventory", | ||
"email_body__multiline_required": "Hello,\n\nThe variant \"VARIANT_TITLE\" is now at 0 inventory, totaled across all locations.\n\n<a href=\"VARIANT_ADMIN_URL\">Manage this variant in Shopify</a>\n\nThanks,\nMechanic, for {{ shop.name }}", | ||
"email_recipient__email_required": "[email protected]" | ||
"email_recipient__email_required": "" | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,22 +8,13 @@ | |
"must_be_published_to_publication_id": "", | ||
"email_subject__required": "\"VARIANT_TITLE\" has hit 0 inventory", | ||
"email_body__multiline_required": "Hello,\n\nThe variant \"VARIANT_TITLE\" is now at 0 inventory, totaled across all locations.\n\n<a href=\"VARIANT_ADMIN_URL\">Manage this variant in Shopify</a>\n\nThanks,\nMechanic, for {{ shop.name }}", | ||
"email_recipient__email_required": "[email protected]" | ||
"email_recipient__email_required": "" | ||
}, | ||
"order_status_javascript": null, | ||
"perform_action_runs_in_sequence": false, | ||
"preview_event_definitions": [], | ||
"script": "{% comment %}\n Run the task manually to get the list of your publications and their IDs\n{% endcomment %}\n\n{% if event.topic == \"mechanic/user/trigger\" or event.preview %}\n {% capture query %}\n query {\n publications (first: 30 ) {\n nodes {\n name\n id\n }\n }\n } \n {% endcapture %}\n\n {% assign result = query | shopify %}\n\n {% action \"echo\" result %}\n{% endif %}\n\n{% if event.topic == \"shopify/inventory_levels/update\" or event.preview %}\n {% capture query %}\n query {\n inventoryLevel(id: {{ inventory_level.admin_graphql_api_id | json }}) {\n item {\n variant {\n displayName\n inventoryQuantity\n legacyResourceId\n product {\n legacyResourceId\n {% if options.must_belong_to_collection_id -%}\n inCollection(id: \"gid://shopify/Collection/{{options.must_belong_to_collection_id}}\")\n {%- endif %}\n {% if options.must_be_published_to_publication_id -%}\n publishedOnPublication(publicationId: \"gid://shopify/Publication/{{options.must_be_published_to_publication_id}}\")\n {%- endif %}\n }\n }\n }\n }\n }\n {% endcapture %}\n\n {% assign result = query | shopify %}\n\n {% if event.preview %}\n {% capture result_json %}\n {\n \"data\": {\n \"inventoryLevel\": {\n \"item\": {\n \"variant\": {\n \"displayName\": \"Short sleeve t-shirt - L / Red\",\n \"inventoryQuantity\": 0,\n \"legacyResourceId\": \"1234567890\",\n \"product\": {\n \"legacyResourceId\": \"1234567890\"\n {% if options.must_belong_to_collection_id -%}\n , \"inCollection\" : \"true\"\n {%- endif %}\n {% if options.must_be_published_to_publication_id -%}\n , \"publishedOnPublication\": \"true\"\n {%- endif %} \n }\n }\n }\n }\n }\n }\n {% endcapture %}\n\n {% assign result = result_json | parse_json %}\n {% action \"echo\" result %}\n {% endif %}\n\n {% assign product_qualifies = false %}\n\n {% assign variantNode = result.data.inventoryLevel.item.variant %}\n\n {% if options.must_belong_to_collection_id != blank and options.must_be_published_to_publication_id != blank %}\n {% error \"You can only filter by collection or publication, not both.\" %}\n {% endif %}\n\n {% if options.must_belong_to_collection_id == blank and options.must_be_published_to_publication_id == bank %}\n {% assign product_qualifies = true %}\n {% elsif options.must_belong_to_collection_id and variantNode.product.inCollection %}\n {% assign product_qualifies = true %}\n {% elsif options.must_be_published_to_publication_id and variantNode.product.publishedOnPublication %}\n {% assign product_qualifies = true %}\n {% endif %}\n \n {% if variantNode.inventoryQuantity == 0 and product_qualifies %}\n {% assign variant_admin_url = \"https://\" | append: shop.domain | append: \"/admin/products/\" | append: variantNode.product.legacyResourceId | append: \"/variants/\" | append: variantNode.legacyResourceId %}\n\n {% assign subject = options.email_subject__required | replace: \"VARIANT_TITLE\", variantNode.displayName | replace: \"VARIANT_ADMIN_URL\", variant_admin_url %}\n {% assign body = options.email_body__multiline_required | replace: \"VARIANT_TITLE\", variantNode.displayName | replace: \"VARIANT_ADMIN_URL\", variant_admin_url %}\n\n {% action \"email\" %}\n {\n \"to\": {{ options.email_recipient__email_required | json }},\n \"subject\": {{ subject | json }},\n \"body\": {{ body | strip | newline_to_br | json }},\n \"reply_to\": {{ shop.customer_email | json }},\n \"from_display_name\": {{ shop.name | json }}\n }\n {% endaction %}\n {% endif %} \n{% endif %}\n", | ||
"subscriptions": [ | ||
"shopify/inventory_levels/update", | ||
"mechanic/user/trigger" | ||
], | ||
"subscriptions": ["shopify/inventory_levels/update", "mechanic/user/trigger"], | ||
"subscriptions_template": "shopify/inventory_levels/update\nmechanic/user/trigger", | ||
"tags": [ | ||
"Alert", | ||
"Email", | ||
"Inventory", | ||
"Out of Stock", | ||
"Products" | ||
] | ||
"tags": ["Alert", "Email", "Inventory", "Out of Stock", "Products"] | ||
} |