Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
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 🙂
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-productvar....
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:
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.
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024