Mechanic Get Mechanic
Task library

Email someone when a certain variant is purchased

This task allows you to send an email to someone when a certain variant is purchased. Requires the variant ID.

Try this task

When it runs

Occurs whenever an order is paid

What you choose

  • Email address
  • Email subject
  • Email body
  • Reply to email address
  • Variant ID

Documentation

This task allows you to send an email to someone when a certain variant is purchased. Requires the variant ID.

This task requires that you enter the variant ID. You can find the variant id using this method:
https://help.shopify.com/en/themes/customization/products/variants/find-variant-id

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

Option types and flags

Task code

{% capture email_action %}
  {
    "action": {
      "type": "email",
      "options": {
        "to": {{ options.email_address__required | json }},
        "subject": {{ options.email_subject__required | json }},
        "body": {{ options.email_body__multiline_required | strip | newline_to_br | json }},
        "reply_to": {{ options.reply_to_email_address | json }},
        "from_display_name": {{ shop.name | json }}
      }
    }
  }
{% endcapture %}

{% if event.preview %}
  {{ email_action }}
{% else %}
  {% for line_item in order.line_items %}
    {% if line_item.variant_id == options.variant_id__number_required %}
      {{ email_action }}
      {% break %}
    {% endif %}
  {% endfor %}
{% endif %}
Mechanic Liquid reference