Hello all,
I found out if I want to create a metafield then I can use this method “useApplyMetafieldsChange()”.
My question is:How can I create a METAOBJECT in the context of Checkout UI Extension React JS base?
Greets
Danyel
Topic: Creating MetaObjects at order level from a Checkout UI Extension (React).
Latest update: A Shopify staff member confirms there is currently no React hook to create MetaObjects within Checkout UI extensions. The only supported approach is to send a network request from the extension to the app’s server, which then creates the MetaObject.
Key terms:
Use case provided: A checkout select box lets users choose a shop name; the developer wants to store the shop’s address as a MetaObject (id, title, street, zipcode, city). Current workaround: store the data as a single string in an order metafield (e.g., “store_name|street|zip|city”) and parse it in the backend.
Open items:
Status: No built-in client-side support for creating (and possibly reading) MetaObjects in Checkout UI extensions; server-side API calls required. Discussion ongoing.
Hello all,
I found out if I want to create a metafield then I can use this method “useApplyMetafieldsChange()”.
My question is:How can I create a METAOBJECT in the context of Checkout UI Extension React JS base?
Greets
Danyel
Hi there ![]()
Thanks for reaching out! You are correct that there currently is not a react hook to allow you to easily create a MetaObject from a Checkout UI extension.
At this time the only way to do so would be to make a network request to your apps server which would in turn create the MetaObject.
Could you share your use case for creating a MetaOject from a Checkout UI extension so that I can share this information with the team?
Thank you for your answer, Lizk.
I have build a select box contains a lot of shop names in the checkout. The user can choose his desired shop name. I want to store the address data of the selected shop name in a metaobject, like this:
id: 42423423
title: ‘store name’,
street: ‘lindenstr.’
zipcode: ‘52343’
city: ‘Bremen’
My workaround is now to save the data in the metafield in this structure:
“store_name|lindenstr. 7|52343|Bremen”
And the BE can split this string into an Array.
But in the end the possibility to create a Metaobject would be fine.
Thanks a lot
Hi Lizk,
Can we read metaobjects in the checkout UI extension? Is there any hook to only just grab data of metaObject in checkout ui?