Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

customAttributes of LineItemMutable

customAttributes of LineItemMutable

raychoi
Visitor
2 0 3

We are trying to add some key/value pairs under order's line item objects.

 

The closest things we could find in the API spec is the customAttributes under LineItemMutable:

raychoi_0-1636598960742.png

 

We could get the field by using graphQL

raychoi_1-1636599134666.png

 

However, we can't find any mutation query for updating this field.

May i know if this field can be created/updated through API (Both graphQL or Restful API is OK), thanks.

Replies 5 (5)

awwdam
Shopify Staff
249 42 38

Hey @raychoi,

Great question here, I wanted to share a few insights to get you started. Utilizing the outlined functionality really depends on what stage of an order you plan or need customAttributes attached. For example, if you want to do this after an order has already been completed with the Admin API, the mutation orderUpdate will allow you to add customAttributes via GraphQL. I'd also suggest exploring some of our other resources, Metafields and the Storefront API may provide insights on similar and related functionalities - Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

raychoi
Visitor
2 0 3

Thanks for your reply.

We checked mutation orderUpdate before, but what we really want is update/create the customAttributes of LineItemMutable object.

May i know if any API could do so?

honzapav
Visitor
1 0 1

@raychoi I have the same problem – @awwdam – any update on this please? 🙏

Ash33
Visitor
3 0 0

Hi there. +1 to this thread.

We are also looking to update the customAttributes of a line item after the order has been placed. It looks like there are two options:
(1) mutate the LineItemMutable object. Not sure how though. Is there some documentation about how we can accomplish that?
(2) mutate checkoutLineItemsUpdate. https://shopify.dev/api/storefront/2022-01/mutations/checkoutLineItemsUpdate.  Again, unsure about how exactly to use the code.

We will be happy with either graphQL or REST API. 

 

Please help!

Thanks.

Simon_G
Tourist
3 0 8

Looking for the same: A way to update customAttributes of lineItems of an order (not customAttributes of an order) after the order was created in shopify (and probably before fulfilment, but potentially even after...).

 

A few use-cases for this:

Use-Case 1: Allow customer to customise things AFTER placing an order (in order to not complicate the order-process). 

Use-Case 2: Allow customer to make changes to attributes (e.g. a gift or engraving text after placing the order)

Use-Case 3: Let staff make those changes from custom dashboard.

Use-Case 4: Traceability (add product information / id etc. to a product after it was shipped). 

 

Only current work-around I see is to store those custom_attributes for line items of orders in a separate database outside shopify. Not nice though.