All things Shopify and commerce
I want to add as url as a product metafield using product metafield.
the metafield type was url at first but keep getting this error, so I changed the type to be single line text but getting the same error. Only the difference is the type part on the error message.
Got error updating metafield: "Value must be a single line text string." For value: "\n\n \n\n\n \n\n\n \n\n\n \n\n\n https://cdn.shopify.com/s/files/1/0630/3085/3829/collections/yamaha-big.png?v=1708457594\n", Type: single_line_text_field
The problem is this part
For value: "\n\n \n\n\n \n\n\n \n\n\n \n\n\n https://cdn.shopify.com/s/files/1/0630/3085/3829/collections/yamaha-big.png?v=1708457594\n"
I don't know why I'm getting this many '\n' s in front and at the end of the url. I tried to truncate those but didn't work.
the value part is coded like this on the flow, update meta field,
{% for collections_item in product.collections %}
{% assign pureUrl = collections_item.image.url | url_decode %}
{{pureUrl}}
{% endfor %}
and this part returns this one
"\n\n \n\n\n \n\n\n \n\n\n \n\n\n https://cdn.shopify.com/s/files/1/0630/3085/3829/collections/yamaha-big.png?v=1708457594\n"
How can I get rid of all the '\n's and get the pure url? I tried url, and originalSrc(in the deprecated section), src(in the deprecated section) but everything returns the same result. I tried the value without assign and ' | url_decode' so only with the {{ collections_item.image.url }}, but returned the same url.
Thank you!
use this {{pureUrl | strip }} - strip removes whitespaces including new line "\n"
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025