Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi all
I have another Flow variable problem, most likely a syntax error but may be my precursor steps.
Objective:
I've set up a metafield 'custom.shipping_weight_grams' which I want to enter the product weight. Sounds easy but there are two scenarios:
- product has no variants
- product has variants
But the variable path for both seems the same, to get to the weight value field you have to go down the variant path. Regardless, I've set up this flow on product creation, then check if product.hasOnlyDefaultVariant then if yes, getproductvariantdata. Then I choose update product metafield, select my field then navigate to
Solved! Go to the solution
This is an accepted solution.
Your metafield is a JSON type and you provided it with text.
\n 200.0 \n
Make sure to remove any whitespace from your liquid around the JSON by using hyphens in your tags like {%- -%} or {{- -}}
The gray arrows mean that path was not followed.
Hi there, I think you may be able to avoid that initial condition as well as the "Get product variant data" action by just using a "For each" to loop through the variants returned with the "Product created" trigger, like so:
Oh, and you may need to use the Update product variant metafield action instead.
Thanks RPiii, I meant to use the productvariant update field but accidentally used the product one. I created the decision fork a couple of steps back when checking the product.hasOnlyDefaultVariant value realising the end point needed to reflect that.
I also took out the getproductvariantdata step but eventually put it back in. The logic says although the create product trigger is singular, when you get data back for variants, it may be a single variant but the code must be written for it to be multiple variants even if the result is only one variant.
The error is still the same regardless.
Hi RP
I revisited your idea and the setup looked a bit different. The variable field for the Update Product Metafield step now looks like this:
{{variantsForeachitem.inventoryItem.measurement.weight.value}}
But it still doesn't work, same error.
The full text of the error reads: "Value must be a stringified JSON object with a value (numeric) and unit (string from one the supported measurement units) fields." For value: "\n 200.0\n", Type: weight
The key elements of this error are:
1. a stringified JSON object with a value (numeric)
2. unit - a string from one of the supported measurement units
Is there another way to write this query specifically addressing those two elements?
This might be significant, why are the arrows grey in these two steps and a zero in the final arrow?
This is an accepted solution.
Your metafield is a JSON type and you provided it with text.
\n 200.0 \n
Make sure to remove any whitespace from your liquid around the JSON by using hyphens in your tags like {%- -%} or {{- -}}
The gray arrows mean that path was not followed.
Hi Paul
Thanks for your reply. I've tried your changes (I actually saw this from you in another discussion) but the same error persists. This is my 'Update Product Metafield' setup:
and the run analysis:
So first, I'm a bit confused by why you are writing a "product" metafield here for each variant...the last update is going to win.
Regarding the error, you didn't read the part about JSON. You need to be entering JSON not a value.
This doc has the various types and their formats:
https://shopify.dev/docs/apps/build/custom-data/metafields/list-of-data-types
Weight is:
{
"value": 2.5,
"unit": "kg"
}
Hi Paul
I didn't understand the significance of the solution when you first mentioned it, I thought the fix was in the liquid for the variable field. I've since created metafields with json type and the flow is working as it should.
Thanks for your help, very much appreciated.
Cheers
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025