Email a report of pick-up orders for the next x days, with Mechanic.

Mechanic is a development and ecommerce automation platform for Shopify. :)

Email a report of pick-up orders for the next x days

Using Zapiet to track store pickups? This task filters for orders that are tagged by Zapiet for pickup, and emails you a report of how many orders are scheduled for each of the next few days. Useful for scanning the week ahead, and blacking out dates that are at capacity.

Runs Occurs when a user manually triggers the task and Occurs every day at midnight (in local time). Configuration includes tagged with, date tag format, days ahead, email recipient, and email subject.

15-day free trial – unlimited tasks

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, 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.

(By the way, have you seen our documentation? Have you joined the Slack community?)

Open source
View on GitHub to contribute to this task
Subscriptions
mechanic/user/trigger
mechanic/scheduler/daily
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
tagged with (required), date tag format (required), days ahead (number, required), email recipient (email, required), email subject (required)
Code
{% assign tag_filter = options.tagged_with__required %}
{% assign date_tag_format = options.date_tag_format__required %}
{% assign days_ahead = options.days_ahead__number_required %}

{% assign seconds_per_day = 86400 %}
{% assign valid_dates = array %}
{% assign order_summary = hash %}

{% for i in (1..days_ahead) %}
  {% assign time_ahead = 0 | plus: seconds_per_day | times: i %}
  {% capture max_date %}{{'now' | date: "%s" | plus: time_ahead | date: date_tag_format }}{% endcapture %}
  {% assign valid_dates[valid_dates.size] = max_date %}
  {% assign order_summary[max_date] = 0 %}
{% endfor %}

{% if event.preview %}
  {% for tag_date in valid_dates %}
    {% assign not_so_random_num = tag_date | date: "%d" | plus: not_so_random_num %}
    {% assign order_summary[tag_date] = not_so_random_num %}
  {% endfor %}
{% else %}
  {% for order in shop.orders.unshipped %}
    {% assign order_tags = order.tags | split: ", " %}
    {% if order_tags contains tag_filter %}
       {% for tag_date in valid_dates %}
          {% if order_tags contains tag_date %}
              {% assign order_summary[tag_date] = order_summary[tag_date] | plus: 1 %}
            {% continue %}
          {% endif %}
       {% endfor %}
    {% endif %}
  {% endfor %}
{% endif %}

{% capture email_body %}
  Hi there,

  There are your orders tagged with `{{ tag_filter }}` for the next {{ days_ahead }} days:
  <ul>{% for tag_date in valid_dates %}<li>{{ tag_date | date: "%a, %b %d" }} - {{ order_summary[tag_date] }}</li>{% endfor %}</ul>

  Thanks,
  Mechanic, (for {{ shop.name }})
{% endcapture %}

{% action "email" %}
  {
    "to": {{ options.email_recipient__email_required | json }},
    "subject": {{ options.email_subject__required | json }},
    "body": {{ email_body | unindent | newline_to_br | json }},
    "reply_to": {{ shop.customer_email | json }},
    "from_display_name": {{ shop.name | json }}
  }
{% endaction %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more
Defaults
Tagged with
Pickup Order
Date tag format
%d-%m-%Y
Days ahead
7
Email subject
Pickup orders by date