Development discussions around Shopify APIs
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:
We could get the field by using graphQL
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.
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
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?
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.
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.
As a business owner, have you ever wondered when your customer's first impression of yo...By Skye Jun 6, 2023
We're excited to announce improvements to the threaded messaging experience in our communi...By TyW May 31, 2023
Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...By Jacqui May 30, 2023