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.
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
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?
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.
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.
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023