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

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

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.

Runs Occurs whenever a customer is updated.

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/customers/update
Tasks use subscriptions to sign up for specific kinds of events. Learn more
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 %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more