How can I remove a specific metafield value in Shopify Flow?

How can I remove a specific metafield value in Shopify Flow?

Zraszacz
Tourist
4 0 1

Hi,

in the theme I'm using, I have the option to display badges that are added via a metafield named custom.badges. The type of this metafield is list.single_line_text_field. In Shopify Flow, I would like a "new" badge to be added to newly added products, and then after 30 days, remove the value of this metafield, which is "new", without removing the metafield itself, because it may contain other values, like "bestseller".
I can only replace the "new" value with another one, but I just want to remove it. I can update the value by adding an array [ "badge1", "badge2" ], but I'm unable to remove a specific value.

Best regards

Reply 1 (1)

paul_n
Shopify Staff
1336 151 307

This might be easier if you use the Run code action. Here's an example of how you can build a list: https://github.com/Shopify/flow-code-examples/tree/main/run-code-examples/product-tags-to-metafields

 

Otherwise, you'll need to use Liquid to remove "badge1" from that list. That will be tricky because you also have to handle commas/brackets/etc. 

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.