Skip to content
Open
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
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ This directory is built automatically. Each task's documentation is generated fr
* [Unpublish products that fall below a rolling sales threshold](./unpublish-products-that-fall-below-a-rolling-sales-threshold)
* [Unpublish products that have been out of stock for x days](./unpublish-products-that-have-been-out-of-stock-for-x-days)
* [Unpublish products when tagged](./unpublish-products-when-tagged)
* [Untag orders when closed/archived](./untag-orders-when-closed-archived)
* [Untag orders when paid](./untag-orders-when-paid)
* [Update empty customer data from addresses](./update-empty-customer-data-from-addresses)
* [Update product description when out of stock](./update-product-description-when-out-of-stock)
Expand Down Expand Up @@ -1298,6 +1299,7 @@ This directory is built automatically. Each task's documentation is generated fr
* [Tag orders in bulk by order name](./tag-orders-in-bulk-by-order-name)
* [Tag orders that have at least x of a certain product](./tag-orders-that-have-at-least-x-of-a-certain-product)
* [Trigger order emails with a tag](./trigger-order-emails-with-a-tag)
* [Untag orders when closed/archived](./untag-orders-when-closed-archived)
* [Untag orders when paid](./untag-orders-when-paid)

### Out of Stock
Expand Down Expand Up @@ -1801,6 +1803,7 @@ This directory is built automatically. Each task's documentation is generated fr
* [Remove a product tag when another tag is added](./remove-a-product-tag-when-another-tag-is-added)
* [Remove an order tag when another tag is added](./remove-a-order-tag-when-another-tag-is-added)
* [Remove matched tags from all products](./remove-specified-tags-from-all-products)
* [Untag orders when closed/archived](./untag-orders-when-closed-archived)
* [Untag orders when paid](./untag-orders-when-paid)

### Variants
Expand Down
43 changes: 43 additions & 0 deletions docs/untag-orders-when-closed-archived/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Untag orders when closed/archived

Tags: Orders, Untag

This task automatically removes specific order tag(s) when orders are closed/archived.

* View in the task library: [tasks.mechanic.dev/untag-orders-when-closed-archived](https://tasks.mechanic.dev/untag-orders-when-closed-archived)
* Task JSON, for direct import: [task.json](../../tasks/untag-orders-when-closed-archived.json)
* Preview task code: [script.liquid](./script.liquid)

## Default options

```json
{
"order_tags_to_remove__array": []
}
```

[Learn about task options in Mechanic](https://learn.mechanic.dev/core/tasks/options)

## Subscriptions

```liquid
shopify/orders/updated
```

[Learn about event subscriptions in Mechanic](https://learn.mechanic.dev/core/tasks/subscriptions)

## Documentation

This task automatically removes specific order tag(s) when orders are closed/archived.

## Installing this task

Find this task [in the library at tasks.mechanic.dev](https://tasks.mechanic.dev/untag-orders-when-closed-archived), and use the "Try this task" button. Or, import [this task's JSON export](../../tasks/untag-orders-when-closed-archived.json) – see [Importing and exporting tasks](https://learn.mechanic.dev/core/tasks/import-and-export) to learn how imports work.

## Contributions

Found a bug? Got an improvement to add? Start here: [../../CONTRIBUTING.md](../../CONTRIBUTING.md).

## Task requests

Submit your [task requests](https://mechanic.canny.io/task-requests) for consideration by the Mechanic community, and they may be chosen for development and inclusion in the [task library](https://tasks.mechanic.dev/)!
26 changes: 26 additions & 0 deletions docs/untag-orders-when-closed-archived/script.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% if event.preview %}
{% capture order_json %}
{
"admin_graphql_api_id": "gid://shopify/Order/12345",
"closed_at" : "2025-01-01T00:00:00+00:00"
}
{% endcapture %}

{% assign order = order_json | parse_json %}
{% endif %}

{% if order.closed_at %}
{% action "shopify" %}
mutation {
tagsRemove(
id: {{ order.admin_graphql_api_id | json }}
tags: {{ options.order_tags_to_remove__array | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}
20 changes: 20 additions & 0 deletions tasks/untag-orders-when-closed-archived.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"docs": "This task automatically removes specific order tag(s) when orders are closed/archived.",
"halt_action_run_sequence_on_error": false,
"name": "Untag orders when closed/archived",
"online_store_javascript": null,
"options": {
"order_tags_to_remove__array": []
},
"perform_action_runs_in_sequence": false,
"preview_event_definitions": [],
"script": "{% if event.preview %}\n {% capture order_json %}\n {\n \"admin_graphql_api_id\": \"gid://shopify/Order/12345\",\n \"closed_at\" : \"2025-01-01T00:00:00+00:00\"\n }\n {% endcapture %}\n\n {% assign order = order_json | parse_json %}\n{% endif %}\n\n{% if order.closed_at %}\n {% action \"shopify\" %}\n mutation {\n tagsRemove(\n id: {{ order.admin_graphql_api_id | json }}\n tags: {{ options.order_tags_to_remove__array | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n{% endif %}\n",
"subscriptions": [
"shopify/orders/updated"
],
"subscriptions_template": "shopify/orders/updated",
"tags": [
"Orders",
"Untag"
]
}