Solved

Create Order Metafield using rest API

mghanem91
Shopify Partner
11 1 1

Hi,

I need to add field to order entity in my shopify store using MetaField.

 

referring to this article :

https://help.shopify.com/en/api/reference/metafield

 

we can see that its easy to create meta field , but how to tell shopify that this meta field for orders ?

 

then I need to update order by setting this meta  field value.

 

to be more clear :

 

My case is integration app, I need to add flag to order entity , The meta field name will be "IsTransfered", after posting the order to extrnal service I need to update this metafield IsTransfered=true.

 

Please let me know if there is other best practice .

 

hint : I'm using ShopifySharp library for .NET.

 

Thanks in advance

 

Accepted Solution (1)

Jason
Shopify Expert
11190 225 2283

This is an accepted solution.

The url for Orders is noted in that docs. eg:

Order/admin/orders/#{id}/metafields.json

 

What are you stuck on?

Out of interest why are you using a metafield and not a tag? Not suggesting that metafields are a bad idea, just curious.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

View solution in original post

Replies 8 (8)

mghanem91
Shopify Partner
11 1 1

Any help

Jason
Shopify Expert
11190 225 2283

This is an accepted solution.

The url for Orders is noted in that docs. eg:

Order/admin/orders/#{id}/metafields.json

 

What are you stuck on?

Out of interest why are you using a metafield and not a tag? Not suggesting that metafields are a bad idea, just curious.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
mghanem91
Shopify Partner
11 1 1

Hi Jason,

There is no reason to use metafield instead of tag, I can use tag , do you thing that dealing with tags will be better in my case ?

 

Regarding to API call , should I do post request to this ?

Order

/admin/orders/#{id}/metafields.json

mghanem91
Shopify Partner
11 1 1

we used the tags, really very clear and simple, thank you @Jason everything is fine with tags.

Agm_Home_Store_
Visitor
1 0 0

Hi Jason,

How to access the order metafields from the order status page with shopify liquid?

The order metafields are created but we are not able to access it on the order status page.

We are able to access for instance, order.line_items but not order.metafields.

Let me know.

 

a2zscilab1
Visitor
3 0 0

can you please help me how to create a metafield in the draft order page. I need to be able to put customer Order # in that field so that the it can printed with the my order number when i am printing the invoice. Please help.

JesusLebt
Tourist
3 0 2


@Jason wrote:

Out of interest why are you using a metafield and not a tag?

Because the tags are accessible through the GUI while metafields are not?


If somebody deletes a tag, a sync job may run again and mess up the data.

 

But it seems it is not possible to create metafields on orders which are created by the api, even the docs says clearly that it should be:

https://shopify.dev/api/admin-rest/2022-01/resources/order#top

JesusLebt
Tourist
3 0 2

Ok, was my fault. It is possible to add a metafield to an order.