Update custom size metafield based on product variant inventory level

Update custom size metafield based on product variant inventory level

Malessi
Visitor
2 0 1

Hi,

 

I'm looking to add metafields to a product based on the variant product inventory levels. The metafield will be for sizes, which will be used for customers to filter with.

Basically, if a variant product inventory level is = 0, then I want to remove the size from the metafield, and if its >0 then add the size to the metafield. In my mind the metafield should be a list of values, so it can store multiple values such as S, M, L, XL.

However I am having trouble figuring out how to do this on shopify flow. Does anyone have any pointers?

Reply 1 (1)

paul_n
Shopify Staff
1339 151 310

You would probably use inventory quantity changed as the trigger. It's not clear how you would go about figuring out which size to remove from the metafield. Probably I would use Run code as it makes it easier to work with the list that is required to set the metafield. There's an example that is pretty close to this here:
https://github.com/Shopify/flow-code-examples/tree/main/run-code-examples/product-tags-to-metafields

 

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.