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

This action type accepts to styles of options - friendly, and explicit. :) Either way, this type requires an array of options – not an object!

Friendly options

  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.

Explicit options

  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 friendly options style. :)

Example: Tagging a customer

{
  "action": {
    "type": "shopify",
    "options": [
      "update",
      [
        "customer",
        12345
      ],
      {
        "tags": "valued-customer"
      }
    ]
  }
}

As defined here, this will create actions that saves the tag valued-customer  to #12345.

Example: Adding images to new products

Assuming a task that runs on products/create , this script will look for products that contain "swatch" in the handle, and will upload a corresponding image for each one:

{% if product.handle contains "swatch" %}
  {
    "action": {
      "type": "shopify",
      "options": [
        "post",
        "/admin/products/{{ product.id }}/images.json",
        {
          "image": {
            "src": "http://example.com/images/color-{{ product.handle }}.png"
          }
        }
      ]
    }
  }
{% endif %}

Did this answer your question?