Auto-fulfill orders when tagged, with Mechanic.

Mechanic is a development platform for Shopify. :)

Auto-fulfill orders when tagged

by Isaac Bowen (isaac@lightward.com)

This task monitors order tags, and when a certain tag is added to an order, it auto-fulfills all unfulfilled items in the order. Optionally, you can choose to notify customers when their order is fulfilled by this task.

Runs when an order is updated. Configuration includes order tag to watch for, ignore if this order tag is found, and notify customer on fulfillment.

15-day free trial – unlimited tasks

Documentation

This task auto-fulfills from the store's default location.

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
when an order is updated (shopify/orders/updated)
Options
order tag to watch for (required), ignore if this order tag is found, notify customer on fulfillment (boolean)
Script
{% if event.preview %}
  {% assign order = hash %}
  {% assign order["id"] = 1234567890 %}
  {% assign order["tags"] = options.order_tag_to_watch_for__required %}
{% endif %}

{% assign order_qualifies = false %}

{% if order.fulfillment_status == nil or order.fulfillment_status == "partial" %}
  {% assign order_tags = order.tags | split: ", " %}
  {% if order_tags contains options.order_tag_to_watch_for__required %}
    {% assign order_qualifies = true %}
  {% endif %}

  {% if order_qualifies and options.ignore_if_this_order_tag_is_found != blank %}
    {% if order_tags contains options.ignore_if_this_order_tag_is_found %}
      {% log message: "Order had the tag to watch for, but it also had the ignore tag. Skipping.", order_tags: order_tags, task_options: options %}
      {% assign order_qualifies = false %}
    {% endif %}
  {% endif %}
{% endif %}

{% if order_qualifies %}
  {% action "shopify" %}
    [
      "post",
      "/admin/orders/{{ order.id }}/fulfillments.json",
      {
        "fulfillment": {
          "location_id": {{ shop.primary_location_id | json }},
          "notify_customer": {{ options.notify_customer_on_fulfillment__boolean | json }},
          "status": "success"
        }
      }
    ]
  {% endaction %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.