Hi,
I am trying to understand the code to add to the value text box of the update product variant metafield action step in a flow.
I want the flow to update a variant metafield with the value from another metafield from the same variant if it has a value.
I am trying to repurpose the shopify code example for listing the colours:
{% capture mf_value %}
{%- for tags_item in product.tags -%}
{%- if tags_item contains “color:” -%}
“{{- tags_item | remove_first: “color:” | strip -}}”,
{%- endif -%}
{%- endfor -%}
{% endcapture -%}
[{{mf_value | remove_last: “,”}}]
by changing it to:
{% capture mf_value %}
{%- for metafields_item in productVariant.metafields -%}
{%- if metafields_item.key contains “sell” -%}
“{{metafields_item.value}}”
{%- endif -%}
{%- endfor -%}
{% endcapture -%}
In my scenario I have a variant metafield with namespace “cross” and key “sell”. If this metafield has text in it I want to pull that value into the variant metafield I am updating with the flow action.
I am currently getting the following error when the flow runs of:
Got error updating metafield: “Value can’t be blank.” For value: “”, Type: single_line_text_field
Can anyone help?
Many thanks
Mark