Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
I don't need anyone to build something for me, but want to scope out if something is possible.
We have a lot of information stored in metafields and I don't like that the people listing our items need to put information in metafields and write some of that same stuff out again in the product description.
The structured data is more useful to us so I'd like to create a Shopify flow action that will use Send HTTP request to construct a fresh product description from the information added in metafields.
my question is, am I barking up the wrong tree here or is this something that could be done. I have had a play around trying to get something to work but soon got out of my depth.
What does the community think? Is this is a valid use of the flow action and is it possible?
Quick addition for why I'm out of my depth here.
I can make it work for a simple change like 'when flow runs add "Hello World" to the product description.
{
"query": "mutation { productUpdate(input: {id: \"{{product.id}}\", descriptionHtml: \"Hello World\"}) { product { id } } }"
}
But what I really want to do is use a capture statement above that to construct a description from the metafields on the product.
So as not to overcomplicate things I'm testing this with a metafield called prods.short_desc which is a multiline text field. I create a new variable called 'new_description' using capture that should pick up the value of this MF which I then put into the mutation.
{% capture new_description %}
{%- for metafields_item in product.metafields -%}
{%- if metafields_item.namespace == "prods" and metafields_item.key == "short_desc" -%}
{{ metafields_item.value }}
{%- endif -%}
{%- endfor -%}
{% endcapture %}
{
"query": "mutation { productUpdate(input: {id: \"{{product.id}}\", descriptionHtml: \"{{new_description}}\"}) { product { id } } }"
}
When run this flow will say 'succeeded' every time but it doesn't actually make any changes. Bit odd and just wondering if this is something I'll never be able to get work or if in theory it could.
Annoyingly I can't edit the response above. It can be ignored. I made a silly error with it. (Seems like the edit functionality isn't there for me to remove it)
Original question still applies though.
I got this to work in the end. If anyone is interested and would like to do something similar I'd be happy to share.