Order Edit - Set Quantity

ejrosie
New Member
2 0 0

Hi, I was hoping you could help me with the Shopify Admin API.

I want to update the quantity of an order using the `orderEditSetQuantity` mutation.
First I do `orderEditBegin`:

        data = """
            mutation beginEdit{{
                orderEditBegin(id: "{}"){{
                    calculatedOrder {{
                        id
                        lineItems(first: 100) {{
                            edges {{
                                node {{ title id quantity variant {{ id }} }}
                            }}
                        }}
                    }}
                }}
            }}
        """.format(orderGid)

 

This gets me a response with this in it:

'id': 'gid://shopify/CalculatedLineItem/9643399872712'


However, when I put that into the `orderEditSetQuantity` mutation, I get `The line item does not exist on the order`

What can I do to edit the quantity of an existing line item in an order?

I tested the `orderEditSetQuantity` mutation on a line item that I added via `addVariantToOrder` mutation, and I am able to set the quantity of it. It had an id like such: `gid://shopify/CalculatedLineItem/aece26f1-4dc5-47bd-8482-bf826179f51c`

Am I doing something wrong? or is the calculatedLineItemId wrong? it matches the normal Line Item ID sent via a Shopify Webhook, so that is why I am suspicious that the calculatedLineItemId is wrong.

0 Likes
_JCC_
Shopify Staff
Shopify Staff
158 21 27

Hey @ejrosie ,

Would you be able to prove the x-request-id from the response headers of the orderEditSetQuantity request that's failing. Based on what you've described this should work. Once we have the request-id we can review our logs to help troubleshoot the issue.

Regards,

John

John C | Developer 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

0 Likes
ejrosie
New Member
2 0 0

Hi, it turned out that the issue was the line item was refunded, and so I guess that doesn't count as a calculated line item any longer.

I created a new order without refunded items and the request worked as expected.

0 Likes