> Documentation index: [Saleor](/llms.txt) · [This section](/developer/llms.txt)
> Source: https://docs.saleor.io/developer/order/order-to-checkout

# Order to Checkout

Saleor allows you to create a checkout from existing orders. This feature can be used when implementing the reordering functionality.

The [`checkoutCreateFromOrder`](/api-reference/checkout/mutations/checkout-create-from-order.md) mutation accepts the `Order` [ID](/api-reference/checkout/mutations/checkout-create-from-order.md#id) as input and returns the new [checkout](/api-reference/checkout/objects/checkout-create-from-order.md#checkout), with the lines from the order attached to it. Lines that are not available (variants deleted, products deleted, variants not published, out of stock, etc.) are returned as [`unavailableVariants`](/api-reference/checkout/objects/checkout-create-from-order.md#unavailable-variants). Any discounts or custom prices attached to the order will not be carried over to the newly created checkout. The price of each checkout line will be based on the current price of the variant.

[`unavailableVariants`](/api-reference/checkout/objects/checkout-create-from-order.md#unavailable-variants) is a list of variants that could not be attached to the checkout. Each [item](/api-reference/checkout/objects/checkout-create-from-order-unavailable-variant.md) has:

-   [`code`](/api-reference/checkout/objects/checkout-create-from-order-unavailable-variant.md#code) that describes why Saleor could not add it to the checkout.
-   [`variantId`](/api-reference/checkout/objects/checkout-create-from-order-unavailable-variant.md#variant-id) that contains the ID of the unavailable variant.
-   [`lineId`](/api-reference/checkout/objects/checkout-create-from-order-unavailable-variant.md#line-id) that contains the ID of the related `orderLine`.
-   [`message`](/api-reference/checkout/objects/checkout-create-from-order-unavailable-variant.md#message) the error message.

The following example shows how the [`checkoutCreateFromOrder`](/api-reference/checkout/mutations/checkout-create-from-order.md) mutation creates a new checkout:

**Mutation**

```graphql
mutation CheckoutCreateFromOrder($id: ID!) {
  checkoutCreateFromOrder(id: $id) {
    errors {
      field
      message
      code
    }
    unavailableVariants {
      message
      code
      variantId
      lineId
    }
    checkout {
      id
      lines {
        quantity
        variant {
          id
        }
      }
    }
  }
}
```

**Variables**

```json
{
  "id": "T3JkZXI6OTM2ZTFlNzEtZDc4NS00MGZiLWI4OTAtYTRmMTk5MTJiOWM2"
}
```

**Result**

```json
{
  "data": {
    "checkoutCreateFromOrder": {
      "errors": [],
      "unavailableVariants": [],
      "checkout": {
        "id": "Q2hlY2tvdXQ6ZjIwMjE3MjAtYzI5Yy00N2NmLWFmYzYtYzZjNGZlOTIyODM2",
        "lines": [
          {
            "quantity": 1,
            "variant": {
              "id": "UHJvZHVjdFZhcmlhbnQ6NDAw"
            }
          },
          {
            "quantity": 3,
            "variant": {
              "id": "UHJvZHVjdFZhcmlhbnQ6MzU0"
            }
          },
          {
            "quantity": 1,
            "variant": {
              "id": "UHJvZHVjdFZhcmlhbnQ6Mzkw"
            }
          }
        ]
      }
    }
  }
}
```

If there are variants that cannot be attached to the checkout, the response will be as follows:

```json
{
  "data": {
    "checkoutCreateFromOrder": {
      "errors": [],
      "unavailableVariants": [
        {
          "message": "Product variant not found",
          "code": "NOT_FOUND",
          "variantId": "UHJvZHVjdFZhcmlhbnQ6NDAw",
          "lineId": "T3JkZXJMaW5lOjc2NWM2Y2JjLTZkZTktNDUwYS1hNjFlLTc5ZmQ1YjkwYmQzMg=="
        },
        {
          "message": "Cannot add lines for unpublished variants.",
          "code": "PRODUCT_NOT_PUBLISHED",
          "variantId": "UHJvZHVjdFZhcmlhbnQ6Mzkw",
          "lineId": "T3JkZXJMaW5lOmJhMGIxYTIyLWUyMGYtNDQyMC04NDgxLTA1MjgxYzdhMWE3MQ=="
        }
      ],
      "checkout": {
        "id": "Q2hlY2tvdXQ6M2VlM2Y3NjEtZTRmYi00MTE5LTgwZmUtNTZmMzQ3MTkxYTFi",
        "lines": [
          {
            "quantity": 3,
            "variant": {
              "id": "UHJvZHVjdFZhcmlhbnQ6MzU0"
            }
          }
        ]
      }
    }
  }
}
```
