Mechanic is a development and ecommerce automation platform for Shopify. :)
Do you sell tickets to recurring events? Do you use a new product variant for each one? Use this task to regularly scan your catalog for product variants that have a date metafield, and to delete variants when their date has passed.
Runs Occurs when a user manually triggers the task and Occurs every day at midnight (in local time). Configuration includes date metafield namespace and date metafield key.
Do you sell tickets to recurring events? Do you use a new product variant for each one? Use this task to regularly scan your catalog for product variants that have a date metafield, and to delete variants when their date has passed.
Run this task manually to immediately scan your product catalog for outdated variants, and delete them. This task will also run nightly, at midnight in your store's timezone.
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 mechanic/scheduler/daily
{% if event.preview %} { "action": { "type": "shopify", "options": [ "delete", ["variant", {{ variant.id | json }}] ] } } {% else %} {% assign today = "now" | date: "%Y-%m-%d" %} {% for product in shop.products.published %} {% if product.variants.size == 1 and product.variants[0].title == "Default Title" %} {% continue %} {% endif %} {% for variant in product.variants %} {% assign expiration_date = variant.metafields[options.date_metafield_namespace__required][options.date_metafield_key__required] %} {% if expiration_date != blank and expiration_date < today %} { "action": { "type": "shopify", "options": [ "delete", ["variant", {{ variant.id | json }}] ] } } {% endif %} {% endfor %} {% endfor %} {% endif %}