how can i get pure url address using the shopify flow app value field?

how can i get pure url address using the shopify flow app value field?

yoonlaser
Shopify Partner
41 0 14

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!

 

 

 

Reply 1 (1)

YOD_Solutions
Shopify Partner
284 29 43

use this {{pureUrl | strip }}  - strip removes whitespaces including new line "\n"

Founder @ JsRates: Custom Shipping Rates
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more about JsRates visit the JsRates home page or JsRates documentation
- Find JsRates on Shopify app store