Hello Everyone,
I have an interesting issue I need help with.
I am using shopify flow to pull the PO# from order notes and add them into a order metafield. I managed to get it to work however I cannot seem to add delineators in the code as the templating language misinterprets it. So this means anything written after the PO will be picked up and moved to the metafield.
Here is the current code in action that doesn’t have :
{%- assign ordernote_lines = order.note | split: “
” -%}
{%- assign dataPO = “” -%}
{%- for line in ordernote_lines -%}
{%- if line contains “PO:” -%}
{%- assign parts = line | split: “PO:” -%}
{%- assign dataPO = line | remove: “PO:” | strip_newlines | strip -%}
{{ dataPO }}
{%- endif -%}
{%- endfor -%}
Here is the code I am trying to implement that uses a delineator that stops the data gathering at the first white space. It uses arrays to split the note into parts to parse out what is needed and what isn’t:
{%- assign ordernote_lines = order.note | split: “
” -%}
{%- assign dataPO = “” -%}
{%- for line in ordernote_lines -%}
{%- if line contains “PO:” -%}
{%- assign parts = line | split: “PO:” -%}
{%- assign po_number = parts[1] | split: " " -%}
{%- assign dataPO = po_number[0] | strip_newlines | strip -%}
{{- dataPO -}}
{%- endif -%}
{%- endfor -%}
<<>>
I get this error when I try to enter the code above and save it.
“order.note.1.0” is invalid. Replace this variable.
What can be done to make it see my array? or is there another way to take the PO from the rest