Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We're looking to set up a flow where we can turn multiple metafields into a new multi-line text field which we can then push off into ebay listings.
All well and good with every metafield type except dimensions which will always output something like this:
- Chest: {"value":32.0,"unit":"INCHES"}
If I was working on a theme page I could easily just get the value and unit, but within flow where the usual dot notation breaks down I can't do that.
I've tried simply using the remove filter to get rid of '{"value":' & '"unit"' & the final "}" but that gives an annoying REGEX error.
Is there a way of extracting the value from a metafield when doing something like this in flow?
the code for the offending bit is below:
{%- for metafields_item in product.metafields -%}
{%- if metafields_item.namespace == "prods" and metafields_item.key == "chest" -%}
<p>
<strong>- Chest:
</strong>
{{ metafields_item.value.value }}</p>
{%- endif -%}
{%- endfor -%}
The flow is:
- Trigger: product added to store
- Action: update product metafield
Solved! Go to the solution
This is an accepted solution.
Yeah, I think including { causes the liquid parser to think liquid is coming. One solution would be to encode the string and then remove the encoded {.
The output of a dimension looks like this:
%7B%22value%22%3A5.0%2C%22unit%22%3A%22INCHES%22%7D
I think removing the %7B and %7D fixes the brackets issue.
{{ mf.value | url_encode | remove: "%7B" | remove: "%7D" | url_decode }}
see https://shopify.dev/docs/api/liquid/filters/url_encode
Yeah, sorry that this isn't yet straight-forward. I think you are on the right track with needing to parse the string. You might be able to use split (https://shopify.dev/docs/api/liquid/filters/split) which turns that string into an array. I think I would do something like:
Also, you can use capture or assign in Flow now, which might help this a bit.
Thanks @paul_n . Will give it a go with assign or capture. It seemed to be the { and } that were causing me the issues. using remove or replace on them gave me the regex based error. Flow must've thought i was doing something else.
Will give a go at using capture and/or assign and see where I get on.
Will keep trying but it seems like step 1 is where the issue is always going to happen. As soon as you try to handle the closing } it will always throw up this error.
So I can quite happily get it down to
- Chest: 32.0 INCHES}
But as soon as any action is done on } it will always fail. Really strange and possibly unavoidable.
This is an accepted solution.
Yeah, I think including { causes the liquid parser to think liquid is coming. One solution would be to encode the string and then remove the encoded {.
The output of a dimension looks like this:
%7B%22value%22%3A5.0%2C%22unit%22%3A%22INCHES%22%7D
I think removing the %7B and %7D fixes the brackets issue.
{{ mf.value | url_encode | remove: "%7B" | remove: "%7D" | url_decode }}
see https://shopify.dev/docs/api/liquid/filters/url_encode
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025