I’ve tried to update an order metafield on order created. The information I want to use for the update is stored in a custom json metafield. It contains:
{
default: {
shipping_days_min: 3,
shipping_days_max: 5,
},
nl: {
shipping_days_min: 6,
shipping_days_max: 12,
}
}
I get access within the flow to the metafield with this code:
{%- for mf in shop.metafields -%}
{%- if mf.namespace == "countries" and mf.key == "shipping_days" -%}
{%- assign shipping_days = mf.value -%}
{{ shipping_days }}
{%- endif -%}
{%- endfor -%}
mf.value / shipping_days contains:
{"default":{"shipping_days_min":3,"shipping_days_max":5},"nl":{"shipping_days_min":1,"shipping_days_max":3}}
I’ve tried to pull out the value for “nl”:
{{ shipping_days["nl"] }}
But then I’ve got an error.
“shop.metafields.value.nl” is invalid. Replace this variable.
I also tried to loop over shipping_days, but it also failed.
Does anyone have any ideas?
Kind regards, Carolin