Auto-delete customers that are created without orders, with Mechanic.

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

Auto-delete customers that are created without orders

Useful for stores that are subjected to bot abuse, this task watches for newly-created customers, and deletes any that don't come with an associated order. Optionally, choose to ignore any customers that are created with a certain tag – helpful if you create customers yourself, via the Shopify admin.

Runs Occurs whenever a customer is created. Configuration includes ignore customers having this tag.

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/create
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
ignore customers having this tag
Code
{% assign delete_customer = false %}

{% if customer.orders.first == nil %}
  {% log "Customer has no orders" %}
  {% assign delete_customer = true %}
{% endif %}

{% if options.ignore_customers_having_this_tag != blank %}
  {% assign customer_tags = customer.tags | split: ", " %}
  {% if customer_tags contains options.ignore_customers_having_this_tag %}
    {% log "Customer had a whitelisted tag; ignoring" %}
    {% assign delete_customer = false %}
  {% endif %}
{% endif %}

{% if event.preview or delete_customer %}
  {% action "shopify" %}
    [
      "delete",
      ["customer", {{ customer.id | json }}]
    ]
  {% endaction %}
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more