Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hey,
I'm not quite getting the syntax required inside update order metafield. I thought I could write normal liquid code, but it seems that I can't? Is that correct? Or am I just missing something?
{% assign am_stock = false %}
{% assign am_special_request = false %}
{% assign am_pre_order = false %}
{% assign am_back_order = false %}
{% assign cm_dropshipping = false %}
{% assign cm_resell = false %}
{% assign s_gardners = false %}
{% assign s_forlagssentralen = false %}
{% for lineItems_item in order.lineItems %}
{% for metafields_item in lineItems_item.variant.metafields %}
{% if metafields_item.namespace == "item" %}
{% if metafields_item.key == "acquisition-method" %}
{% for am in metafields_item.value %}
{% if am.title.value == "Stock" %}
{% assign am_stock = true %}
{% elsif am.title.value == "Special request" %}
{% assign am_special_request = true %}
{% elsif am.title.value == "Pre-order" %}
{% assign am_pre_order = true %}
{% elsif am.title.value == "Back-order" %}
{% assign am_back_order = true %}
{% endif %}
{% endfor %}
{% endif %}
{% if metafields_item.key == "completion-method" %}
{% for cm in metafields_item.value %}
{% if cm.title.value == "Dropshipping" %}
{% assign cm_dropshipping = true %}
{% elsif cm.title.value == "Resell" %}
{% assign cm_resell = true %}
{% endif %}
{% endfor %}
{% endif %}
{% if metafields_item.key == "supplier" %}
{% for s in metafields_item.value %}
{% if s.title.value == "Gardners" %}
{% assign s_gardners = true %}
{% elsif s.title.value == "Forlagssentralen" %}
{% assign s_forlagssentralen = true %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% if order.lineItems > 1 %}
{% if cm_dropshipping and cm_resell %}
"TRUE"
{% elsif cm_dropshipping and cm_resell != true %}
{% if s_gardners and s_forlagssentralen %}
"TRUE"
{% else %}
"FALSE"
{% endif %}
{% elsif am_stock and am_pre_order %}
"TRUE"
{% elsif am_stock and am_back_order %}
"TRUE"
{% elsif am_special_request and am_pre_order %}
"TRUE"
{% elsif am_special_request and am_back_order %}
"TRUE"
{% else %}
"FALSE"
{% endif %}
{% else %}
FALSE
{% endif %}
I'm trying to update a metafield to set to true if the delivery will be split and false if it won't. But I'm getting this error when I try to write this inside value:
Correct this workflow issue: An internal error occured. Try again later.
Hi Rdaniel,
It looks like there is a problem with this snippet:
{% for cm in metafields_item.value %}
{% if cm.title.value == "Dropshipping" %}
{% assign cm_dropshipping = true %}
{% elsif cm.title.value == "Resell" %}
{% assign cm_resell = true %}
{% endif %}
{% endfor %}
Specifically, the `metafields_item.value` field is unknown to the Liquid compiler at compile time, so it cannot be iterated over. I believe it will interpret it as a `string`.
Hopefully that helps you debug further!
Ok. I forgot to mention that the metafields_item is a metaobject reference... So will it still be interpret as ´string´?
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