How to automatically delete past workshop dates in product variants?

Topic summary

A merchant selling barista workshops as product variants (each variant representing a specific date/time) wants to automatically delete past workshop dates so customers cannot purchase expired sessions.

Current Setup:

  • Workshops are products with type “workshop”
  • Each variant represents a different date/time (e.g., “January 1, 2024 08:30”)
  • Variants include custom metafield date values

Attempted Solution:
The user tried creating a Shopify Flow to:

  • Run nightly checks on workshop products
  • Compare variant metafield dates against today’s date
  • Delete variants where the date has passed

Key Issues Identified:

  • Cannot use Liquid syntax in Flow conditions (major blocker)
  • Metafield values cannot be queried directly in “Get product variant data” queries
  • Date comparison logic consistently returns false
  • In Liquid, use {{"now"}} instead of {{"today"}} for current date

Workarounds Suggested:

  • Manually run workflow by bulk-selecting products in Admin
  • Use metafield values to construct queries with available filters
  • Match date format exactly in variant titles for string-based filtering

Status: Unresolved. The user struggles with Flow’s limitations and documentation clarity. Shopify is reportedly working on expanded code capabilities (timing TBD).

Summarized with AI on November 14. AI used: claude-sonnet-4-5-20250929.

Hi,

besides coffee we are selling barista workshops. Every workshop (like barista basic workshop) is a product (product type “workshop”). The product has different variants based on the workshop dates like 1. January 2024 08:30, 13. January 14:30 etc. each variant has a custom meta date field too.

I’m trying to create a flow which checks every night the all products with product_type: workshop and delete those variants which are <= today date (or the date of the schedule) so people cannot buy workshops which have already passed.

I think the action of “Get product variant data” should help here, but I’m unsure about the query. Something like product_type:“Kurs” AND product_title starts with {{scheduledAt}} or something :slightly_smiling_face:
Any ideas?

Definitely do not make up the syntax for the query…it will likely return all results on failure (because the API works that way). To test if something works, I heartily recommend using the free app GraphiQL (to test queries), as documented here: https://help.shopify.com/en/manual/shopify-flow/reference/data

The filters available in the query are here: https://shopify.dev/docs/api/admin-graphql/2023-07/objects/QueryRoot#connection-queryroot-productvariants.

You guessed “product_type” correctly but it’s just “title”.

The hard part of this is the date…because it’s just a string. I think you could run this every day and delete yesterday’s variants pretty easily. Something like

title:{{ scheduledAt | date_minus: "1 day" | date: "%e. %B %Y" }}*

That date format needs to exactly match the beginning of your titles.

You could then build a workflow to handle all the existing variants. Something like:

  • Product added to store
  • For each variant
    • If variant includes that date
    • Delete variant

You could run this workflow manually in the Admin by bulk selecting products

thanks, but didn’t work. So I made a flow:

get all product data from lessons, then check if the metafield = today for each item

but it always says the argument is false:

I’m sending me an email where I check the same argument - if today == the metafield value

when I receive the email, it looks like this: and in the first email it says that it’s the same but it doesn’t trigger my mail I’m sending when my flow argument is true.

so the problem must be in the checkif. I tried equals to, is at least one etc.

but it seems not to work. Any ideas?

You cannot use liquid in conditions.

OMG, ok. I think flows would be much better if you just could code stuff. Haha.
Hum, and I assume metafield values cannot be accessed in the get product variant data query, right?

You can’t query by them yet, but you can use the values to construct your query, if that makes sense (for one of the available query filters).

We are working on the ability to use code in more places, but timing on when we can release is still TBD. Keep an eye on the change log.

Will try this. btw: the documentation of the query paramaters and syntex isn’t really clear. Glad there are third party documentation which are clearer and simpler.

Which 3p docs are you using?

I’m referring to https://shopify.dev/docs/api/usage/search-syntax

Trying to get a product variant data without the if afterwards by using this query via sku:
sku:Kurs-BaristaBasis-{{ “today” | date: “%Y%m%d” }}*
the skus have this format Kurs-BaristaBasis-20231201-1730

but it doesn’t work

We point there because the filters can change over time.

FYI, “today” is not a variable in liquid. Try “now” instead.