Publish a certain collection, daily with Mechanic.

Mechanic is the one-tool-does-it-all automation app for Shopify. :)

Publish a certain collection, daily

by Isaac Bowen (team@usemechanic.com)

Use this task with the companion unpublishing task (see this task's documentation) to make a certain collection of products available on a schedule, and unavailable on another schedule.

Runs 9 hours after every Monday at midnight, 9 hours after every Tuesday at midnight, 9 hours after every Wednesday at midnight, 9 hours after every Thursday at midnight, 9 hours after every Friday at midnight, 10 hours after every Saturday at midnight, and 10 hours after every Sunday at midnight. Configuration includes collection.

15-day free trial – unlimited tasks

Documentation

For best results, pair this task with Unpublish a certain collection, daily, from our task library.

To configure this task, navigate to the collection you'd like to use in the Shopify admin. Copy just the numeric portion from the URL (e.g. 12345, if the collection URL is https://example.myshopify.com/admin/collections/12345), and use this as the "Collection ID" setting for this task.

Out of the box, this task will publish everything in this collection at 9am on weekdays, and 10am on weekends. To adjust this, click the "Show Advanced" link, and tweak the "Subscriptions" setting to taste. Each line represents midnight in your shop's local timezone, plus whatever number of hours you prefer. For example, mechanic/scheduler/tuesday+13.hours would mean Tuesday at 1pm.

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Events
9 hours after every Monday at midnight (mechanic/scheduler/monday+9.hours)
9 hours after every Tuesday at midnight (mechanic/scheduler/tuesday+9.hours)
9 hours after every Wednesday at midnight (mechanic/scheduler/wednesday+9.hours)
9 hours after every Thursday at midnight (mechanic/scheduler/thursday+9.hours)
9 hours after every Friday at midnight (mechanic/scheduler/friday+9.hours)
10 hours after every Saturday at midnight (mechanic/scheduler/saturday+10.hours)
10 hours after every Sunday at midnight (mechanic/scheduler/sunday+10.hours)
Options
collection (required)
Script
{% if event.preview %}
  {
    "action": {
      "type": "shopify",
      "options": [
        "update",
        [
          "product",
          12345
        ],
        {
          "published": true
        }
      ]
    }
  }
{% else %}
  {% assign collection = shop.collections[options.collection_id__required] %}

  {% for product in collection.products %}
    {
      "action": {
        "type": "shopify",
        "options": [
          "update",
          [
            "product",
            {{ product.id }}
          ],
          {
            "published": true
          }
        ]
      }
    }
  {% endfor %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.