Mechanic is a development 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 when a user triggers the task, when a product is created, and when a product is 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, 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.
{% 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 %}