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

Mechanic is a development and ecommerce automation platform for Shopify. :)

Auto-copy order notes to the customer's note

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

Runs Occurs whenever an order is updated. Configuration includes note prefix.

15-day free trial – unlimited tasks

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, 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.

(By the way, have you seen our documentation? Have you joined the Slack community?)

Open source
View on GitHub to contribute to this task
Subscriptions
shopify/orders/updated
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
note prefix
Code
{% 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 %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more
Defaults
Note prefix
Order {{ order.name }}: