Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to help you close in on the last few products that are missing cost values. Trigger this task manually to process your entire catalog, or let this task update tags as needed for products you create or update.
Runs Occurs when a user manually triggers the task, Occurs whenever a product is created, and Occurs whenever a product is updated, or whenever a product is ordered, or whenever a variant is added, removed, or updated. Configuration includes tag for cost missing.
Use this task to help you close in on the last few products that are missing cost values. Trigger this task manually to process your entire catalog, or let this task update tags as needed for products you create or update.
Use the "Run task" button to scan all products in your catalog. Or, create/update products as usual, and this task will maintain tagging accordingly.
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?)
mechanic/user/trigger shopify/products/create shopify/products/update
{% if event.preview %} {% action "shopify" %} mutation { tagsAdd( id: "gid://shopify/Product/1234567890" tags: {{ options.tag_for_cost_missing__required | json }} ) { userErrors { field message } } } {% endaction %} {% elsif event.topic == "mechanic/user/trigger" %} {% for product in shop.products %} {% assign missing_cost = true %} {% for variant in product.variants %} {% if variant.inventory_item.cost != blank %} {% assign missing_cost = false %} {% break %} {% endif %} {% endfor %} {% assign product_tags = product.tags | split: ", " %} {% if missing_cost %} {% unless product_tags contains options.tag_for_cost_missing__required %} {% action "shopify" %} mutation { tagsAdd( id: {{ product.admin_graphql_api_id | json }} tags: {{ options.tag_for_cost_missing__required | json }} ) { userErrors { field message } } } {% endaction %} {% endunless %} {% elsif product_tags contains options.tag_for_cost_missing__required %} {% action "shopify" %} mutation { tagsRemove( id: {{ product.admin_graphql_api_id | json }} tags: {{ options.tag_for_cost_missing__required | json }} ) { userErrors { field message } } } {% endaction %} {% endif %} {% endfor %} {% elsif event.topic == "shopify/products/create" or event.topic == "shopify/products/update" %} {% assign missing_cost = true %} {% for variant in product.variants %} {% if variant.inventory_item.cost != blank %} {% assign missing_cost = false %} {% break %} {% endif %} {% endfor %} {% assign product_tags = product.tags | split: ", " %} {% if missing_cost %} {% unless product_tags contains options.tag_for_cost_missing__required %} {% action "shopify" %} mutation { tagsAdd( id: {{ product.admin_graphql_api_id | json }} tags: {{ options.tag_for_cost_missing__required | json }} ) { userErrors { field message } } } {% endaction %} {% endunless %} {% elsif product_tags contains options.tag_for_cost_missing__required %} {% action "shopify" %} mutation { tagsRemove( id: {{ product.admin_graphql_api_id | json }} tags: {{ options.tag_for_cost_missing__required | json }} ) { userErrors { field message } } } {% endaction %} {% endif %} {% endif %}