Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
I'm trying (and failing) to create a Flow which is triggered when an order is created and updates a metafield on the variant for each line item. The aim is to have a metafield containing the date when the variant was last ordered.
After a few false starts, I created a Flow as follows:
(The "log output" actions can be ignored - they are for debugging.)
The "run code" action is fairly simple - it just takes the variant ID for each line item and returns an array of variant IDs:
However, the flow is getting stuck on the next action, when it tries to get product variant data. It is configured like this:
But the Flow log is showing this:
The "log output" action has the same code as the "get product variant data" query, and it produces output like this (but with real variant IDs):
id:gid\://shopify/ProductVariant/999999999 OR id:gid\://shopify/ProductVariant/999999999 OR id:gid\://shopify/ProductVariant/999999999
That looks to me like a valid search query.
Where am I going wrong? Is my search query incorrect? Perhaps the colons should be escaped differently? Have I missed something somewhere else?
Perhaps I am over-complicating this (seemingly straightforward) task, and is there an easier/better way of doing it. Is there an easy way to pull the last purchase date of a variant via the Admin API instead of using Flow?
Any thoughts/suggestions would be very welcome.
Solved! Go to the solution
This is an accepted solution.
I think you want just the ID number not the full gid:
Might be helpful to test out queries in graphiql to troubleshoot.
This is an accepted solution.
I think you want just the ID number not the full gid:
Might be helpful to test out queries in graphiql to troubleshoot.
Of course, so simple! A small change to the Run Code action did the job:
Many thanks for your help 😊
Nice! You got it!
How did you end up updating the variant metafields? Did you do it with an http request to an app or using the update variant metafield flow action?
I used the "Update product variant metafield" action. Here's the final flow:
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024