Skip to content

Shopify order notifications

Parse Shopify order emails

Shopify emails the store's staff for every new order. Forward those notifications to a mailhooks.cc address and this layout reads the order number, the customer and the totals, and turns the order summary into line items.

Use this layoutFree plan included: 2 layouts per endpoint.
The email
From
Acme Store <orders@acme-store.example>
Subject
[Acme Store] Order #1042 placed by Jane Doe
Jane Doe placed order #1042 on Oct 29 at 10:14 am.

Order summary
Linen shirt × 2  $78.00
Canvas tote × 1  $24.00

Subtotal  $102.00
Shipping  $6.00
Total  $108.00 USD

Shipping address
Jane Doe
1 Main Street
Springfield
What your endpoint delivers
{
  "parsed": {
    "status": "matched",
    "layout": {
      "id": "shopify-orders",
      "name": "Shopify orders"
    },
    "fields": {
      "order": "1042",
      "customer": "Jane Doe",
      "subtotal": "102.00",
      "shipping": "6.00",
      "total": "108.00",
      "currency": "USD"
    },
    "lineItems": [
      {
        "product": "Linen shirt",
        "quantity": "2",
        "price": "78.00"
      },
      {
        "product": "Canvas tote",
        "quantity": "1",
        "price": "24.00"
      }
    ]
  }
}

The layout

It matches the email by its subject, reads each field with an RE2 pattern, and turns the list into line items. Edit any of it in the endpoint's settings, where the preview tries it on an email you captured as you type.

{
  "id": "shopify-orders",
  "name": "Shopify orders",
  "match": {
    "conditions": [
      {
        "field": "email",
        "name": "subject",
        "op": "contains",
        "value": "placed by"
      }
    ]
  },
  "fields": [
    {
      "name": "order",
      "from": "subject",
      "pattern": "Order #(\\d+)"
    },
    {
      "name": "customer",
      "from": "subject",
      "pattern": "placed by (.+)$"
    },
    {
      "name": "subtotal",
      "from": "text",
      "pattern": "Subtotal\\s+[$€£]?([0-9][0-9.,]*)"
    },
    {
      "name": "shipping",
      "from": "text",
      "pattern": "Shipping\\s+[$€£]?([0-9][0-9.,]*)"
    },
    {
      "name": "total",
      "from": "text",
      "pattern": "(?m)^Total\\s+[$€£]?([0-9][0-9.,]*)"
    },
    {
      "name": "currency",
      "from": "text",
      "pattern": "(?m)^Total\\s+\\S+\\s+([A-Z]{3})"
    }
  ],
  "lineItems": {
    "from": "text",
    "start": "Order summary",
    "end": "Subtotal",
    "pattern": "(?m)^(?P<product>.+?) × (?P<quantity>\\d+)\\s+[$€£]?(?P<price>[0-9][0-9.,]*)\\s*$"
  }
}

More senders