Auto-copy order notes to the customer's note with Mechanic.

Mechanic is the one-tool-does-it-all automation app for Shopify. :)

Auto-copy order notes to the customer's note

by Isaac Bowen (team@usemechanic.com)

This task appends order notes to the related customer's note, whenever the order note changes.

Runs when an order is created and when an order is updated. Configuration includes note prefix.

15-day free trial – unlimited tasks

Documentation

This task appends order notes to the related customer's note, whenever the order note changes.

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 created (shopify/orders/create)
when an order is updated (shopify/orders/updated)
Options
note prefix
Script
{% assign order_qualifies = false %}

{% if order.note != blank %}
  {% unless order.customer.note contains order.note %}
    {% assign order_qualifies = true %}
  {% endunless %}
{% endif %}

{% if event.preview or order_qualifies %}
  {% assign new_order_note = order.customer.note | append: newline | append: newline | append: options.note_prefix | append: order.note | strip %}

  {% if event.preview or new_order_note.size <= 5000 %}
    {% action "shopify" %}
      [
        "update",
        [
          "customer",
          {{ order.customer.id | json }}
        ],
        {
          "note": {{ new_order_note | json }}
        }
      ]
    {% endaction %}
  {% else %}
    {% capture error_body %}
      Hello,
          
      Mechanic was unable to add to the customer note for the following customer, for the following related order:

      Customer: https://{{ shop.domain }}/admin/customers/{{ order.customer.id }}
      Order: https://{{ shop.domain }}/admin/orders/{{ order.id }}

      Thanks,
      Mechanic
    {% endcapture %}

    {% action "email" %}
      {
        "to": {{ shop.email | json }},
        "subject": {{ "Mechanic error: customer note too long for order " | append: order.name | json }},
        "body": {{ error_body | unindent | strip | newline_to_br | json }},
        "reply_to": {{ shop.customer_email | json }},
        "from_display_name": {{ shop.name | json }}
      }
    {% endaction %}
  {% endif %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Note prefix
Order {{ order.name }}: