Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I want to extract a single line text value from the customer note once the customer is created but I am having trouble with new line processing in shopify flow and liquid.
My update metafield action looks like this:
{% assign lines = customer.note | split: '\n' %}
{% for line in lines %}
{% if line contains 'website' %}
{% assign website = line | remove: 'website:' | strip %}
{% endif %}
{% endfor %}
but it won't split on \n no matter what. I have tried putting in an actual newline in the code, i have tried replacing the newline. Nothing seems to work. The only thing that does work is strip_newlines, but then I cannot separate it anymore.
There is also this technique for splitting into lines:
{% capture newline %}
{% endcapture %}
{% assign lines = customer.note | split: newline %}
Just make sure there is no stray spaces inside capture
Hey! @tinus1424,
You're right—Shopify Flow and Liquid can behave unexpectedly when it comes to newline characters (\n), especially because how they're stored or passed in customer.note might not be consistent (e.g. it might be \r\n, actual newlines, or nothing visible).
Here’s a better approach to ensure you correctly split on actual line breaks in Shopify Flow:
{% assign lines = customer.note | newline_to_br | split: '<br />' %}
{% for line in lines %}
{% if line contains 'website:' %}
{% assign website = line | remove: 'website:' | strip %}
{% endif %}
{% endfor %}