Mechanic Get Mechanic
Task library

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.

Try this task

When it runs

Occurs whenever an order is created

What you choose

  • Supported fsa values
  • Email recipients
  • Email subject
  • Email body

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.

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/orders/create
How task subscriptions work

Option types and flags

Task code

{% 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 Liquid reference

Default option values

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 }}