Mechanic is a development platform for Shopify. :)
Using Judge.me for reviews? Use this task to keep a counter for each customer's reviews, stored as a metafield on the customer record. And, auto-tag customers as they reach different levels of review counts - useful for granting discounts or special access to repeat reviewers.
Runs when a Judge.me review is created. Configuration includes metafield namespace required, metafield key, and tags to apply for review counts.
Using Judge.me for reviews? Use this task to keep a counter for each customer's reviews, stored as a metafield on the customer record. And, auto-tag customers as they reach different levels of review counts - useful for granting discounts or special access to repeat reviewers.
After installing this task, activate Judge.me's Mechanic integration: Settings > Integrations > Admin Backend > Mechanic.
Notes:
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.
{% assign customer = shop.customers[review.reviewer.external_id] %} {% if customer or event.preview %} {% assign current_review_count = customer.metafields[options.metafield_namespace_required][options.metafield_key__required] | default: 0 %} {% assign next_review_count = current_review_count | plus: 1 %} {% assign metafield = hash %} {% assign metafield["namespace"] = options.metafield_namespace_required %} {% assign metafield["key"] = options.metafield_key__required %} {% assign metafield["value_type"] = "integer" %} {% assign metafield["value"] = next_review_count %} {% assign params = hash %} {% assign params["metafield"] = metafield %} {% if event.preview %} {% assign metafield_url = "/admin/customers/1234567890/metafields.json" %} {% else %} {% assign metafield_url = "/admin/customers/" | append: customer.id | append: "/metafields.json" %} {% endif %} {% action "shopify" "post", metafield_url, params %} {% assign next_review_count_as_string = next_review_count | append: "" %} {% assign tag = options.tags_to_apply_for_review_counts__keyval[next_review_count_as_string] %} {% if tag != blank %} {% capture query %} mutation { tagsAdd( id: {% if event.preview %}"gid://shopify/Customer/1234567890"{% else %}{{ customer.admin_graphql_api_id | json }}{% endif %} tags: {{ tag | json }} ) { node { id } userErrors { field message } } } {% endcapture %} {% action "shopify" query %} {% endif %} {% endif %}