Use Metafield Comparison in Low Inventory Flow

Use Metafield Comparison in Low Inventory Flow

BarnabyT
Visitor
1 0 0

Hi-

 

We have different products that need to trigger low stock warnings at different inventory levels, and we have those set in a custom metafield on our products (called 'Low Stock Warning'). I found the template for 'Get notified by email when product variant inventory is low', but that only lets me set a single number for all products. Is there any way to adapt that to use the number stored in the metafield as the point of comparison instead? I tried looking at the various metafield options, but I'm very confused...

Replies 4 (4)

paul_n
Shopify Staff
1300 148 297

The problem you'll run into is that metafield values appear as strings to Flow. So you can't compare them as numbers except in liquid. We are working on some improvements to this so you can use the metafield like this.

 

If your logic can live in an action via liquid, for example to control what is show in a notification, you could do this. But if you need to control sending the email, you'll need to wait. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
dl-mondo
Visitor
1 0 0

Looking for the same. But is it possible with the getProducts action like in my attachment? I can't write liquid so I tried with GPT 😄 Bildschirm­foto 2024-02-29 um 22.26.33.png

paul_n
Shopify Staff
1300 148 297

That field is for writing a query string for the API. I'm not sure what you are trying to do there. Click on the help below the field to see how to use the fields (or try another option in the dropdown to see the syntax).

Also, I'm not sure that comment syntax will work. I've only used {% comment %}test{% endcomment %}

 

Finally, you can now use Run code to get a specific metafield value and output it in way that can be used in a condition (like as a number). 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

Kalen_Jordan
Shopify Partner
656 26 107

Since this isn't possible currently in Flow, I thought I'd recommend our automation app mesa as a solution here. I could build you out a template for this if you were interested.