Goal: remove a line item from an already placed order and add a new variant via API. The requester couldn’t find a direct delete endpoint.
Proposed approach: use the Admin GraphQL orderEditSetQuantity mutation to set the target line item’s quantity to 0, effectively removing it. A code snippet and variables were provided, showing use of CalculatedOrder and CalculatedLineItem IDs. (The mutation example is central to understanding.)
Key terms: CalculatedOrder and CalculatedLineItem are entities used during the order editing process to stage changes before finalizing an order.
Open question: the requester asked how to obtain the CalculatedLineItem ID (e.g., whether it becomes available after the order is placed). This was not answered in the thread.
Additional resource: a community article was shared that discusses removing line items via REST/GraphQL.
Status: no final resolution. Action needed: determine how to retrieve the appropriate CalculatedLineItem ID within the order editing workflow to apply the mutation and then proceed to add the new variant.
To remove an item from an order, you can use the orderEditSetQuantity mutation and modify the line item quantity to zero. It’ll look something like the below: