Mechanic Get Mechanic
Task library

Auto-add phone numbers to unfulfilled orders, when the customer is updated

When a customer update occurs, if the customer has a phone number on file, this task will look for unshipped or partially shipped orders that don't yet have a phone number on file, and will add the customer's phone number to those orders.

Try this task

When it runs

Occurs whenever a customer is updated

Task code and subscriptions

You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.

Subscriptions

shopify/customers/update
How task subscriptions work

Task code

{% if event.preview %}
  {% action "shopify" %}
    [
      "update",
      ["order", {{ order.id | json }}],
      {"phone": {{ customer.phone | json }}}
    ]
  {% endaction %}
{% elsif customer.phone != blank %}
  {% assign orders = customer.orders.any.unshipped | concat: customer.orders.any.partial %}

  {% for order in orders %}
    {% if order.phone != blank %}
      {% continue %}
    {% endif %}

    {% action "shopify" %}
      [
        "update",
        ["order", {{ order.id | json }}],
        {"phone": {{ customer.phone | json }}}
      ]
    {% endaction %}
  {% endfor %}
{% endif %}
Mechanic Liquid reference