Tags: Inventory, Products, Unpublish
This task watches for inventory updates. When a product's total inventory becomes 0 or less, the current time will be recorded for that product. Then, on an hourly basis, this task will unpublish any products with a recorded out-of-stock time of at least x days ago.
- View in the task library: tasks.mechanic.dev/unpublish-products-that-have-been-out-of-stock-for-x-days
- Task JSON, for direct import: task.json
- Preview task code: script.liquid
{
"number_of_days_to_wait_before_unpublishing__number_required": null,
"sales_channel_names__required_array": [
"Online Store"
],
"only_include_products_matching_this_search_query": null,
"test_mode__boolean": true
}
Learn about task options in Mechanic
shopify/inventory_levels/update
mechanic/scheduler/hourly
mechanic/user/trigger
Learn about event subscriptions in Mechanic
This task watches for inventory updates. When a product's total inventory becomes 0 or less, the current time will be recorded for that product. Then, on an hourly basis, this task will unpublish any products with a recorded out-of-stock time of at least x days ago.
Notes:
- The first time the hourly scan runs, it may encounter products that were already out of stock, before this task was installed. For those products, the current time will be recorded as their out-of-stock time. This means that these products will wait for another x days before being automatically unpublished.
- If a product that this task unpublishes is manually published, and its total inventory is still 0 or less, this task will unpublish it again during its next hourly scan.
- This task includes a test mode. Enable it to have the task report what it would do, if test mode was disabled.
Find this task in the library at tasks.mechanic.dev, and use the "Try this task" button. Or, import this task's JSON export – see Importing and exporting tasks to learn how imports work.
Found a bug? Got an improvement to add? Start here: ../../CONTRIBUTING.md.
Submit your task requests for consideration by the Mechanic community, and they may be chosen for development and inclusion in the task library!