Reorder
Build a fresh admin draft cart from a previous order's items — the same flow as the Reorder button on the admin order-view screen.
Operation
| Operation | Type | Purpose |
|---|---|---|
createAdminReorder | Mutation | Create a draft cart from a past order |
Input
| Field | Type | Notes |
|---|---|---|
orderId | ID! | The order's resource IRI — "/api/admin/orders/{id}". |
Why
orderId, notid? API Platform GraphQL reservesidas the resource IRI, so a mutation input field namedidcollides. We useorderIdfor the order reference.
Behaviour
This is the same action as the admin Reorder button:
- A new draft admin cart is created for the order's customer (not the customer's own active cart).
- Every item from the order is re-added to that draft cart. Per-item failures are swallowed.
- Returns
success,message, and the newcartId.
Errors
The mutation enforces the same 3-check guard as the admin panel. Each failure returns the errors[] array (the data.createAdminReorder payload is null) with a distinct message per failure mode:
| Condition | errors[0].message |
|---|---|
Order was placed as guest (is_guest = 1) | Reorder is not supported for guest orders. |
| At least one item's product is no longer purchasable | One or more items in this order are no longer available for purchase. |
Admin's role lacks sales.orders.create | You do not have permission to create orders. |
sales.order_settings.reorder.admin config is off | Reorder by admin is disabled in store settings. |
Sample error response
json
{
"errors": [
{
"message": "Reorder is not supported for guest orders.",
"extensions": { "category": "invalid_input" }
}
],
"data": { "createAdminReorder": null }
}
