Send an email alert when an incoming Canadian order has an unsupported FSA, with Mechanic.

Mechanic is a development platform for Shopify. :)

Send an email alert when an incoming Canadian order has an unsupported FSA

Useful for Canadian stores with limited shipping zones, this task inspects the FSA (the first three characters of the postal code) for each order's shipping address. If an FSA is found that's not on a preconfigured list, this task sends an email to the recipients of your choice.

Runs when an order is created. Configuration includes supported fsa values, email recipients, email subject, and email body.

15-day free trial – unlimited tasks

Documentation

Useful for Canadian stores with limited shipping zones, this task inspects the FSA (the first three characters of the postal code) for each order's shipping address. If an FSA is found that's not on a preconfigured list, this task sends an email to the recipients of your choice.

The FSA list must be comprised of FSAs in the format 'A1A', without the quotation marks. The FSAs must be separated by commas and no spaces. The FSAs can be entered in any order.

The task will log orders whose FSA was found in the available FSA list.

It also displays the available FSA list in json format to more easily catch if there were errors in inputting the availability list.

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.

Open source
View on GitHub to contribute to this task
Events
when an order is created (shopify/orders/create)
Options
supported fsa values (required, array), email recipients (required), email subject (required), email body (required, multiline)
Script
{% if event.preview %}
  {% assign order = hash %}
  {% assign order["shipping_address"] = hash %}
  {% assign order["shipping_address"]["name"] = "#1234" %}
  {% assign order["shipping_address"]["zip"] = "XXX123" %}
{% endif %}

{% assign supported_fsa_values = options.supported_fsa_values__required_array %}
{% assign order_fsa = order.shipping_address.zip | slice: 0, 3 %}

{% if supported_fsa_values contains order_fsa %}
  {% assign order_disqualified = false %}
  {% log %}
    {{ "The FSA (" | append: order_fsa | append: ") for order: " | append: order.name | append: " is on the supported list, and should be in our delivery area." | json }}
  {% endlog %}
{% else %}
  {% assign order_disqualified = true %}
{% endif %}

{% if order_disqualified %}
  {% action "email" %}
  {
    "to": {{ options.email_recipients__required | json }},
    "subject": {{ options.email_subject__required | strip | json }},
    "body": {{ options.email_body__required_multiline | newline_to_br | strip | json }},
    "reply_to": {{ shop.customer_email | json }},
    "from_display_name": {{ shop.name | json }}
  }
  {% endaction %}
{% endif %}

{% log order_fsa: order_fsa, supported_fsa_values: supported_fsa_values %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Supported fsa values
["K1A"]
Email subject
Order {{ order.name }} may be out of delivery zone
Email body
Hi team,

Please see details for order {{ order.name }}:

https://{{ shop.myshopify_domain }}/admin/orders/{{ order.id }}

It looks like this might be out of our delivery zone!

Thanks,
- Mechanic, for {{ shop.name }}