How do I create a meta object on order level in a Checkout UI Extension

Danyel1980
Shopify Partner
7 0 3

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

Replies 3 (3)

lizk
Shopify Staff
246 58 72

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?

To learn more visit the Shopify Help Center or the Community Blog.

Danyel1980
Shopify Partner
7 0 3

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

dev_dnShop
Shopify Partner
26 1 0

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?