Auto-tag orders that contain bundles, with Mechanic.

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

Auto-tag orders that contain bundles

Use this task to automatically detect and tag orders that contain a complete bundle of products. Configure this task with as many bundles as you like, specifying a tag to add and a list of required SKUs.

Runs Occurs whenever an order is created. Configuration includes tags and required skus.

15-day free trial – unlimited tasks

Documentation

Use this task to automatically detect and tag orders that contain a complete bundle of products. Configure this task with as many bundles as you like, specifying a tag to add and a list of required SKUs.

Fill in "Tags and required SKUs" option with tags on the left, and a comma-delimited lists of SKUs on the right.

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/orders/create
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
tags and required skus (keyval, required)
Code
{% assign tags_to_save = order.tags %}
{% assign order_skus = order.line_items | map: "sku" | uniq %}

{% for pair in options.tags_and_required_skus__keyval_required %}
  {% assign tag = pair[0] %}
  {% assign required_skus = pair[1] | split: "," %}

  {% assign matched_sku_count = 0 %}
  {% for order_sku in order_skus %}
    {% if required_skus contains order_sku %}
      {% assign matched_sku_count = matched_sku_count | plus: 1 %}
    {% endif %}
  {% endfor %}

  {% if event.preview or matched_sku_count == required_skus.size %}
    {% assign tags_to_save = tags_to_save | add_tag: tag %}
  {% endif %}
{% endfor %}

{% if event.preview or tags_to_save != order.tags %}
  {
    "action": {
      "type": "shopify",
      "options": [
        "update",
        [
          "order",
          {{ order.id | json }}
        ],
        {
          "tags": {{ tags_to_save | json }}
        }
      ]
    }
  }
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more
Defaults
Tags and required SKUs
{"Summer bundle"=>"SUN01,SUN02,SUN03", "Winter bundle"=>"SNOW01,SNOW02,SNOW03"}