Anything that Shopify allows developers to do, Mechanic lets you automate. This means that you can create, update, or delete nearly anything in your Shopify account.

Here are some ideas:

  • Tagging customers
  • Creating a draft order for every customer who signs up
  • Emailing your staff when an order is delivered

Mechanic has a few built-in tasks that take advantage of this action, but the possibilities are literally limitless. Work with a developer or hit that chat button in the corner to explore your options. :)

For developers

The "shopify" action has three styles of usage:

  • Resourceful REST, which uses Shopify's REST Admin API in a style reminiscent of ActiveResource
  • Explicit REST, which uses Shopify's REST Admin API with explicitly defined values for HTTP method, url, and body
  • GraphQL, which uses Shopify's GraphQL API

Resourceful REST

Accepts an array of options, containing these elements in order:

  1. Operation
    Must be one of "create" , "update" , or "delete" .
  2. Resource specification
    When creating, use a single string (e.g. "customer" ).
    When updating or deleting, use an array (e.g. ["customer", 123] ).
  3. An object of attributes
    Only applies to creating and updating.

A task which tags a customer upon ordering might look like this:

{% action "shopify" %}
  [
    "update",
    [
      "customer",
      {{ order.customer.id | json }}
    ],
    {
      "tags": {{ order.customer.tags | add_tag: "ordered" | json }}
    }
  ]
{% endaction %}

Explicit REST

Accepts an array of options, containing these elements in order:

  1. Operation
    Must be one of "post" , "put" , or "delete" 
  2. Request path
    Literally, the path you want to request from Shopify – the entire path. For example, /admin/orders.json .
  3. An object of attributes
    Same as the resourceful options style. :)

A task which tags a customer upon ordering might look like this:

{% action "shopify" %}
  [
    "put",
    "/admin/customers/{{ order.customer.id }}.json",
    {
      "tags": {{ order.customer.tags | add_tag: "ordered" | json }}
    }
  ]
{% endaction %}

GraphQL

Accepts a valid GraphQL query.

A task which tags a customer upon ordering might look like this:

{% assign customer = shop.customers[order.customer.id] %}

{% action "shopify" %}
  mutation {
    tagsAdd(
      id: {{ customer.admin_graphql_api_id | json }}
      tags: "ordered"
    ) {
      userErrors {
        field
        message
      }
    }
  }
{% endaction %}
Did this answer your question?