With the craziness around shipping into the USA these days, we are trying to make better use of the Country of Origin data stored by Shopify. As this COO data is not exposed by Shopify to themes, templates etc, I created a metafield and populated it with the COO data.
Now I am attempting to create a scheduled flow that we can use to keep the metafield in sync with the main COO when updates take place. The latest query I have tried in Flow is;
(product.variants.inventoryItem.countryCodeOfOrigin:*) AND (product.variants.inventoryItem.countryCodeOfOrigin:<product.metafields.custom.SecondCOO.value)
What I want it to do is return all products that have a COO and that COO does not match the COO in my metafield. I have tried a number variations of this query with no luck. The asterisk to denote non-null does not seem to work on the COO and I can’t find a comparator that works on the COO vs the singe line text metafield.
Flow does not have a “product updated” trigger (some apps may provide it though). Same for “Get inventory items”…
So probably your best bet would be to run your task on schedule, use query to get products which were updated since the last run then loop over these products and compare your data using “run code” and condition (as condition alone can’t compare 2 variables).
I’d also look at the triggers like “Product variant inventory changed” and “Inventory item created” – COO would not change without one of those, right?
Hello @City_Store,
Great initiative! Shopify Flow doesn’t support direct comparison between inventoryItem.countryCodeOfOrigin and metafields in query filters. Instead, use a Flow trigger like “Product updated,” then add a condition block using Liquid to compare product.variants.inventoryItem.countryCodeOfOrigin with product.metafields.custom.SecondCOO.value. If they differ, proceed with an action to update the metafield. This workaround ensures sync without relying on unsupported query syntax.
Hi Shana, thank you. I had made a couple of attempts to solve the issue using a liquid block before resorting to the straight query. With the liquid block I was having similar issues with the comparison not working but it may have just been a syntax issue I made. Can you suggest a quick condition block that should work for these fields?