I am using the advanced flow action to get order data from the last day and then send an internal email.
I won’t go over the full use case but I’d like to get product titles only when that product has a certain metafield value
This is what I have (where the CAPS things are replaced with the real values)
{% for getOrderData_item in getOrderData %}
{% for lineItems_item in getOrderData_item.lineItems %}
{% if lineItems_item.product.metafields.namespace == “NAMESPACE” and lineItems_item.product.metafields.key == “KEY” and lineItems_item.product.metafields.value == VALUE%}
{{lineItems_item.product.title}}
{% endif %}
{% endfor %}
{% endfor %}
This returns nothing at all despite the metafield value definitely being present.
I might start be removing the IF statement and echoing out the metafield values like {{ metafields_item.value }}. If it has metafields and they don’t print out then, your scoping idea may be correct.
I’ve removed the if statements and used this instead
{% for getOrderData_item in getOrderData %}
{% for lineItems_item in getOrderData_item.lineItems %}
{% for metafields_item in lineItems_item.product.metafields %}
{{lineItems_item.product.title}} {{metafields_item.value}}
{% endfor %}
{% endfor %}
{% endfor %}
That gives me a list of the products with their various metafield values next to it
Product 1 Metafield_value
Product 1 Metafield_value
Product 1 Metafield_value
Product 2 Metafield_value
etc.
This seems to imply that I can access those metafields and product.title in those loops so the question remains why the if statement stops it working
Really odd. It’s not a particularly complex bit of liquid and I think the syntax is good and the mf namespace.keys.values all labelled correctly.
So really not sure why I can’t limit the data like this.
p.s. I have also tried putting a condition in front of this to look for the metafield namespace.key.value but that also doesn’t work.
Are you sure you want to check the value in the “if” and not the “namespace” and “key”? Are you sure the key name is what you think it is? FYI, Flow does not use dot notation with metafields yet so things like “metafields.custom.my_key” will not work.
That metafield is a true/false one I want to only output the product titles where it was set as true.
The actual use case is that we have some items that as a charity shop we have some items that are gift aidable. I would like to be able to output product details in from the advanced workflow where the gift aid metafield is set to true.
It’s odd that you say flow doesn’t work with dot notation because I’m using it in a few other places fine. unless I’m misunderstanding what you’re saying of course.
By dot notation, I mean you cannot access metafields specifically like {{ order.metafields.my_name.my_key }} as you can in storefront liquid. Otherwise it works.
I think your condition has the wrong value or key name. I think to check for a boolean metafield it may be case sensitive so has to be the string “True”
At this point I’m thinking that the advanced workflows maybe just won’t be able to do what we thought they could. The only thing I can think of would be whether we could put the metafield value filter on getOrderData action itself.