Shopify Flow: Update Metafield Custom Code Issues

Trying to update the product metafield through the code below, and getting “Value can’t be blank.” For value: “” error.

Does anyone have ideas on how to mitigate this?

{% capture mf_value %}
{% assign preOrderText = “” %}
{% for variants_item in product.variants %}
{% if variants_item.inventoryPolicy == “continue” %}
{% if product.tags contains “Limited” %}
{% assign preOrderText = “Ships in 7-10 days” | strip | replace: ‘\n’, ’ ’ %}
{% else %}
{% assign preOrderText = “Pre-order, ships in 2-3 days” | strip | replace: ‘\n’, ’ ’ %}
{% endif %}
{{ preOrderText }}
{% endif %}
{% endfor %}
{% endcapture -%}
{{ mf_value | strip_newlines | strip | replace: ‘\n’, ’ ’ }}

1 Like