FROM CACHE - en_header

Updating line item properties of a order

Solved
AlejandroLoz
Shopify Partner
9 0 2

Hello Community,

Do you know if we can update line item properties of a order through API? 

We have access to "order" entity and we can update its properties through API. Attempting to update "line items" seems like being ignored. 

This is mentioned in some other messages as "not possible" but if you see reference, "line_items" property of a order is not "read only".
order reference screenshot

 

Has anyone ever updated line items, or is it true "it's not possible"?

Accepted Solution (1)

Accepted Solutions
Zameer
Shopify Staff
Shopify Staff
297 31 88

This is an accepted solution.

Hey there,

 

It's definitely true that order `line_items` can not be updated once they are created.

 

The 'lines_items" property on the Order object isn't set to 'read-only', as it's possible to set the `line_items` when originally making a POST request to create the order. However, subsequent PUT requests to update the order `line_items` would be ignored.

 

If you need to update the `line_items` on an order, you would instead have to create a new order with the updated information.

View solution in original post

Replies 9 (9)
Zameer
Shopify Staff
Shopify Staff
297 31 88

This is an accepted solution.

Hey there,

 

It's definitely true that order `line_items` can not be updated once they are created.

 

The 'lines_items" property on the Order object isn't set to 'read-only', as it's possible to set the `line_items` when originally making a POST request to create the order. However, subsequent PUT requests to update the order `line_items` would be ignored.

 

If you need to update the `line_items` on an order, you would instead have to create a new order with the updated information.

Tommy_Ivarsson
Shopify Partner
1 0 4

Now the docs state

After an order is created, you can change only a few of its attributes using the API. You cannot change the items or the quantities in an order.

However one could wonder why Shopify doesn't mark these properties somehow in the order property list.

 

Zameer, isn't it very odd that the Admin UI can perform updates on line_items whilst the API can't?

Liquify
Shopify Expert
84 0 44

I agree here - hit a brick wall with this today.  Our use case is kinda unique but I'd expect these to be editable via the api.  I guess we'll do something ugly instead to work around it.

★★★ Need help setting up your Shopify store? Hire me here: https://liquify.design ★★
idanhertz
New Member
1 0 0

Hey Zameer,

 

I saw your solution and i want to make sure that I have been understand it correctly.

 

Order's line_items can be updated in the Order's view in the admin panel (using edit).

 

However, I cant updated those items with API

 

Thanks!!

 

Idan

HandHugs
Shopify Expert
189 1 51

I dont see any way for an admin to edit the line item properties... can you guys fill me in on how to do it, if it's possible from the shopify Admin side?

Al_Priest
Tourist
33 0 1

From reading the current docs

...from the Admin UI you can only remove line item properties of an existing order

...from the REST API you cannot update an existing order

...from the GraphQL API you can update an existing order, but the line item properties are not modelled (so you can't read/write them at all)

zainmirza60
Tourist
12 0 1

Dear Sir,

-- Rest API is workless if you are in order edit mode. Nothing work with order line items editing.

-- But with graphQL you can edit order line items here is very wonderful tutorial  (https://shopify.dev/tutorials/edit-an-existing-order-with-admin-api)

-- But I am thinking above from there how to edit the shipping line items and discount to placed order with GQL any help please.

 

sillycube
Shopify Partner
700 16 106

I think the OP mixed up line item properties and line item. Line item properties are under a line item

In admin portal UI, you can remove line item properties one by one

With graphQL API, you can edit orders. You can edit line item but not line item properties

With rest API, you cannot edit line item nor line item properties.

I am looking for removing line item properties with order edit API. But look like it's not possible at this moment. I would like to have the capability to remove line item properties with the order edit API.

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
akash777
Tourist
3 0 0
Use line instead of id to update/set properties of line item in the cart.

 

$.ajax({
     url: '/cart/change.js',
     type: 'post',
     dataType: 'json',
     data: {
         line: 1,
         quantity: 5,
         properties: {
             'foo': 'bar',
             'bar': 'foo'
          }
      },
      success: function(cart){ /* Yay!  The cart updated! */ }
})