Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi all,
For my products, I have a metafield that defines length (.custom.length), and one that defines shape(.custom.shape).
I am trying to create a flow, where when triggered, updates the cutline metafield (theme.cutline) to their length and shape values. All three metafields are single lined texts. (So for example length value = Medium and shape value = Oval, cutline value with be "Medium Oval"
After research I see that for liquid I need to do something like this:
{% for metafields_item in product.metafields %} {% if metafields_item.namespace == "custom" and metafields_item.key == "length" %} {{metafields_item.value}} {% endif %} {% endfor %}
I've also tried this:
{% for metafields_item in product.metafields %} {% if metafields_item.namespace == "custom" and metafields_item.key == "length" %} {% assign length_value = metafields_item.value %} {% endif %} {% endfor %} {{ length_value }}
But both returns this when run:
Got error updating metafield: "Value must be a single line text string." For value: "\n \n Medium\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n\n", Type: single_line_text_field
Is there any way I can fix this? Thank you!
Solved! Go to the solution
This is an accepted solution.
Try using hyphens to eliminate the newlines:
{%- for metafields_item in product.metafields -%} {%- if metafields_item.namespace == "custom" and metafields_item.key == "length" -%} {{- metafields_item.value -}} {%- endif -%} {%- endfor -%}
This is an accepted solution.
Try using hyphens to eliminate the newlines:
{%- for metafields_item in product.metafields -%} {%- if metafields_item.namespace == "custom" and metafields_item.key == "length" -%} {{- metafields_item.value -}} {%- endif -%} {%- endfor -%}
This worked perfectly! Thank you!
Flow just launched improved metafield support, which makes it easier to find and use metafield data in Flow: https://changelog.shopify.com/posts/shopify-flow-access-typed-metafields
Hi, just tried it. Worked perfectly, thanks!
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024