Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent tagging existing products when first seen by task #297

Merged
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
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ This directory is built automatically. Each task's documentation is generated fr
### In stock

* [Add Option Name as a Variant Metafield for In Stock Variants](./add-option-names-as-variant-metafields-for-in-stock-variants)
* [Auto-tag new products by "back in stock" age](./auto-tag-new-products-by-back-in-stock-age)
* [Publish back-in-stock products](./publish-back-in-stock-products)
* [Tag products as in- or out-of-stock, by location ID](./tag-products-as-in-or-out-of-stock-by-location-id)
* [Tag products as in- or out-of-stock](./tag-products-as-in-or-out-of-stock)
Expand Down Expand Up @@ -1063,7 +1064,6 @@ This directory is built automatically. Each task's documentation is generated fr
* [Add Option Name as a Variant Metafield for In Stock Variants](./add-option-names-as-variant-metafields-for-in-stock-variants)
* [Auto-associate variants with a delivery profile, by metafield value](./auto-associate-variants-with-a-delivery-profile-by-metafield-value)
* [Auto-copy customer metafields to new orders](./auto-copy-customer-metafields-to-new-orders)
* [Auto-tag new products by "back in stock" age](./auto-tag-new-products-by-back-in-stock-age)
* [Copy draft order metafields to orders](./copy-draft-order-metafields-to-orders)
* [Copy prefixed tags to metafields](./copy-prefixed-tags-to-metafields)
* [Copy product metafields to each product's tags](./copy-product-metafields-to-each-products-tags)
Expand Down
25 changes: 14 additions & 11 deletions docs/auto-tag-new-products-by-back-in-stock-age/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Auto-tag new products by "back in stock" age

Tags: Auto-Tag, Metafields, Products, Watch
Tags: Auto-Tag, In stock, Products, Watch

This task monitors changes to inventory level, records the time at which a product's total inventory passes your configured threshold, and then maintains a set of tags indicating how recently the product returned to "back in stock" status.

Expand All @@ -12,11 +12,10 @@ This task monitors changes to inventory level, records the time at which a produ

```json
{
"back_in_stock_inventory_level__number_required": "50",
"back_in_stock_inventory_level__number_required": "1",
"product_tags_and_maximum_age_in_days__keyval_number_required": {
"new-1": "1",
"new-5": "5",
"new-9999": "9999"
"new-5": "5"
},
"run_daily__boolean": true,
"run_hourly__boolean": false
Expand All @@ -28,13 +27,15 @@ This task monitors changes to inventory level, records the time at which a produ
## Subscriptions

```liquid
shopify/products/create
shopify/inventory_levels/update

{% if options.run_hourly__boolean %}
mechanic/scheduler/hourly
{% elsif options.run_daily__boolean %}
mechanic/scheduler/daily
{% endif %}
mechanic/user/trigger
mechanic/shopify/bulk_operation

{% if options.run_daily__boolean %}mechanic/scheduler/daily{% endif %}
{% if options.run_hourly__boolean %}mechanic/scheduler/hourly{% endif %}
```

[Learn about event subscriptions in Mechanic](https://learn.mechanic.dev/core/tasks/subscriptions)
Expand All @@ -45,11 +46,13 @@ This task monitors changes to inventory level, records the time at which a produ

This task operates in two phases.

Phase one runs in response to inventory level changes. When a change brings a product's total inventory to at or above your configured threshold, a [metafield](https://help.shopify.com/en/manual/metafields) will be added to your product, indicating when it returned to "back in stock" status. (Note: when this task encounters a product for the first time, and the product is _already_ considered "back in stock", the task will record the current time.)
Phase one runs in response to inventory level changes. When a change brings a product's total inventory to at or above your configured threshold, the task will record the "back in stock" time for that product.

Phase two occurs when you run this task manually, or when it is run daily or hourly. In this phase, the task scans every product in your shop and updates tags in bulk according to the task's configuration and according to the recorded "back in stock" time for each product.

Phase two occurs when you run this task manually, or when it is run daily or hourly. In this phase, the task scans every product in your Shopify account, and updates tags in bulk, according to the task's configuration and according to the recorded "back in stock" time for each product.
Configure "Product tags and maximum age in days" with product tags on the left, and the maximum product age to consider on the right. For example, a product tag of "new-5" with a maximum age in days of "5" will be maintained on all products that have a "back in stock: time within the last 5 days. Once a product ages beyond that threshold, this task will remove that tag during the next "phase two" run.

Configure "Product tags and maximum age in days" with product tags on the left, and the maximum product age to consider on the right. For example, a product tag of "new-5" with a maximum age in days of "5" will be added to all products that were created/published within the last 5 days. Once a product ages beyond that threshold, this task will remove that tag during the next "phase two" run.
**Note:** when this task first encounters a product on either an inventory level change or a bulk scan, the task will record the current time as the "first seen time". No tags will be added to a product until a "back in stock" time is recorded that is *newer* than the "first seen time". For newly created products, the "first seen time" will instead be set to the product creation date, which will ensure that the product's initial "back in stock" time will always be newer.

## Installing this task

Expand Down
Loading