# Edit an order after it was placed

> Add items, change quantities and commit the change with orderEditBegin, orderEditAddVariant, orderEditSetQuantity and orderEditCommit.

Page: https://lintelagency.com/resources/graphql/order-editing

## In short

To edit a placed order, start with orderEditBegin, which returns a calculated order: a draft copy of the order. Stage changes on it with orderEditAddVariant, orderEditSetQuantity and similar mutations, then apply them all at once with orderEditCommit. Nothing changes on the real order until you commit. Only unfulfilled line items can be edited, and your app needs write_order_edits.

## Facts

- **API:** Admin GraphQL API
- **Operations:** orderEditBegin, orderEditAddVariant, orderEditSetQuantity, orderEditCommit
- **Access scope:** write_order_edits
- **API version:** 2026-10
- **Last checked:** 2 November 2026

## How to use it

1. Send BeginOrderEdit with the order ID. Keep the calculated order ID and the calculated line item IDs it returns.
2. Stage changes: AddItemToOrder adds a variant, ChangeQuantity lowers or raises a line item. Use restock: true to put removed units back in stock.
3. Check userErrors after each step; a staged change that fails leaves the others in place.
4. Send CommitOrderEdit. With notifyCustomer: true the customer gets the updated order by email.

## Code

### order-edit-begin.graphql

```graphql
mutation BeginOrderEdit($orderId: ID!) {
  orderEditBegin(id: $orderId) {
    calculatedOrder {
      id
      lineItems(first: 20) {
        nodes {
          id
          title
          quantity
          editableQuantity
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

### order-edit-begin.variables.json

```json
{
  "orderId": "gid://shopify/Order/1234567890"
}
```

### order-edit-begin.response.json

```json
{
  "data": {
    "orderEditBegin": {
      "calculatedOrder": {
        "id": "gid://shopify/CalculatedOrder/1234567890",
        "lineItems": {
          "nodes": [
            {"id": "gid://shopify/CalculatedLineItem/1111111111", "title": "Linen shirt", "quantity": 2, "editableQuantity": 2}
          ]
        }
      },
      "userErrors": []
    }
  }
}
```

### order-edit-add-variant.graphql

```graphql
mutation AddItemToOrder($calculatedOrderId: ID!, $variantId: ID!, $quantity: Int!) {
  orderEditAddVariant(id: $calculatedOrderId, variantId: $variantId, quantity: $quantity, allowDuplicates: false) {
    calculatedLineItem {
      id
      title
      quantity
    }
    userErrors {
      field
      message
    }
  }
}
```

### order-edit-add-variant.variables.json

```json
{
  "calculatedOrderId": "gid://shopify/CalculatedOrder/1234567890",
  "variantId": "gid://shopify/ProductVariant/2222222222",
  "quantity": 1
}
```

### order-edit-add-variant.response.json

```json
{
  "data": {
    "orderEditAddVariant": {
      "calculatedLineItem": {
        "id": "gid://shopify/CalculatedLineItem/2222222222",
        "title": "Wool scarf",
        "quantity": 1
      },
      "userErrors": []
    }
  }
}
```

### order-edit-set-quantity.graphql

```graphql
mutation ChangeQuantity($calculatedOrderId: ID!, $lineItemId: ID!, $quantity: Int!) {
  orderEditSetQuantity(id: $calculatedOrderId, lineItemId: $lineItemId, quantity: $quantity, restock: true) {
    calculatedLineItem {
      id
      quantity
    }
    userErrors {
      field
      message
    }
  }
}
```

### order-edit-set-quantity.variables.json

```json
{
  "calculatedOrderId": "gid://shopify/CalculatedOrder/1234567890",
  "lineItemId": "gid://shopify/CalculatedLineItem/1111111111",
  "quantity": 1
}
```

### order-edit-set-quantity.response.json

```json
{
  "data": {
    "orderEditSetQuantity": {
      "calculatedLineItem": {
        "id": "gid://shopify/CalculatedLineItem/1111111111",
        "quantity": 1
      },
      "userErrors": []
    }
  }
}
```

### order-edit-commit.graphql

```graphql
mutation CommitOrderEdit($calculatedOrderId: ID!, $notifyCustomer: Boolean, $staffNote: String) {
  orderEditCommit(id: $calculatedOrderId, notifyCustomer: $notifyCustomer, staffNote: $staffNote) {
    order {
      id
      name
      totalOutstandingSet {
        shopMoney {
          amount
          currencyCode
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

### order-edit-commit.variables.json

```json
{
  "calculatedOrderId": "gid://shopify/CalculatedOrder/1234567890",
  "notifyCustomer": true,
  "staffNote": "Swapped one shirt for a scarf at the customer's request."
}
```

### order-edit-commit.response.json

```json
{
  "data": {
    "orderEditCommit": {
      "order": {
        "id": "gid://shopify/Order/1234567890",
        "name": "#1001",
        "totalOutstandingSet": {
          "shopMoney": {
            "amount": "-14.00",
            "currencyCode": "EUR"
          }
        }
      },
      "userErrors": []
    }
  }
}
```

## Limits and edge cases

- Only unfulfilled line items can be edited, and orders placed before January 1, 2019 or archived orders can’t be edited.
- If the total changes, a balance may have to be collected or refunded. A negative totalOutstandingSet means the store owes the customer money; refund it with refundCreate.
- Setting a quantity to 0 removes the line item from the order.
- Shopify’s guide also lists requirements for editing orders in a currency other than the store’s, and for subscription orders.

## Questions

### Can I edit a Shopify order after it is placed?

Yes, as long as the line items are unfulfilled. Use orderEditBegin, stage the changes, then orderEditCommit, or edit the order in the Shopify admin.

### Does editing an order refund the customer automatically?

No. If the new total is lower, the difference shows as an outstanding amount owed to the customer; create the refund yourself.

### What is a calculated order?

A working copy of the order that holds your staged edits and the recalculated totals. It becomes the real order only when you commit it.

## Shopify documentation

- [Edit existing orders](https://shopify.dev/docs/apps/build/orders-fulfillment/order-management-apps/edit-orders)
- [orderEditBegin](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderEditBegin)
- [orderEditCommit](https://shopify.dev/docs/api/admin-graphql/latest/mutations/orderEditCommit)

## Related

- [Refund an order](https://lintelagency.com/resources/graphql/refund-order)
- [Fulfill an order with a tracking number](https://lintelagency.com/resources/graphql/fulfillment-with-tracking)

License: MIT. Free to use in your own store and in client work.
