A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi,
I'm looking to create order metafields with the admin rest api. However, I also want that value visible in the UI, since some metafields created via the API are not shown in the UI. I was planning on creating the metafield definition in the UI and then use the admin rest api to create an order with the value for the metafield. However, that doesn't look possible because at the point that the order is created, the metafield is null and therefore not retrievable. If I write the appropriate metafield value in the ui after the order is created, the admin API can grab the metafield. But, that defeats the purpose of doing it programmatically. This is the closest article on the topic: https://community.shopify.com/c/shopify-apis-and-sdks/not-able-to-retrieve-list-of-metafields/td-p/1...
Is this possible and if not, what do you suggest? My fallback plan is to make use of line item properties, which would show the values in the UI. But, they are not changeable in the UI, which I'd like to have changeable in the UI if possible.
Thanks.
Where do you have, or from where do you get the value you'd like to store in the metafield of the order? Is it derived from something that has to do with the products, customer, etc, or is it a fixed value?
Ralf
Metafields created via the API can show in the Admin. A while back you would have been correct but things have changed. GraphQL might be new to you but for things like this it's worth learning.
Start looking at GraphQL and creating metafield definitions so they'll be placed into the Admin UI.
There's a workshop that can give you the basics if this is new to you. It's well written and easy to follow.
However, that doesn't look possible because at the point that the order is created, the metafield is null and therefore not retrievable.
This part of the flow I'd want to understand more. There should not be a blocker to update a metafield after order creation so might be missing something here.