Skip to content

Reorder Customer Order

About

The reorderOrder mutation allows authenticated customers to quickly re-add items from a previous order to their cart. This enables:

  • One-click reordering of frequently purchased items
  • Convenient replenishment of consumables or recurring purchases
  • Enhanced customer experience by reducing re-selection friction
  • Support for reordering from any order status (pending, completed, shipped, canceled, etc.)

When items are reordered:

  • Items are added to the customer's current/active cart
  • Out-of-stock or unavailable items are silently skipped
  • The mutation succeeds if at least one item is added
  • Item quantities, prices, and options are preserved from the original order
  • Inventory is decremented as normal for new cart items

Use this feature to:

  • Enable "Quick Reorder" buttons in order history pages
  • Support one-click replenishment ordering
  • Improve customer retention through convenient purchasing
  • Reduce cart abandonment for repeat purchases
  • Implement "Frequently Reordered" sections

Authentication

This mutation requires customer authentication:

  • Authenticated customers: Provide a valid customer authentication token in the Authorization header. Obtain this token via the Customer Login API.
Authorization: Bearer <accessToken>
X-STOREFRONT-KEY: <storefrontKey>

Arguments

ArgumentTypeRequiredDescription
input.orderIdInt!✅ YesThe numeric ID of the order to reorder items from.

Possible Returns

FieldTypeDescription
successBoolean!true if at least one item was added to cart, false if no items could be added.
messageString!Human-readable message with outcome (number of items added, reasons for failures, etc.). Localized.
orderIdInt!The numeric ID of the source order.
itemsAddedCountInt!Number of items successfully added to the cart.

Business Logic

  1. Authentication Check: Verifies customer is logged in
  2. Ownership Validation: Ensures order belongs to the authenticated customer
  3. Item Iteration: Loops through each item in the order
  4. Availability Check: For each item:
    • Verifies product still exists
    • Checks if item is purchasable
    • Validates stock availability
  5. Add to Cart: Calls cart add-to-cart logic for available items
  6. Silent Failure: Items that can't be added are skipped without error
  7. Success Response: Returns count of successfully added items
  8. Inventory Update: Stock is decremented for each item added

Success Scenarios

ScenarioSuccess?itemsAddedCountNotes
All 5 items available✅ Yes5Complete reorder
3 of 5 items available✅ Yes3Partial reorder (2 out of stock)
Only 1 item available✅ Yes1Single item reorder
No items available❌ No0All items discontinued/out of stock

Error Handling

Order Not Found

json
{
  "errors": [
    {
      "message": "Order not found (ID: 99999)",
      "extensions": {
        "category": "user_error"
      }
    }
  ]
}

Cause: Order ID doesn't exist or belongs to another customer

Solution: Verify the order ID and ensure it belongs to the authenticated customer

No Items Could Be Added

json
{
  "data": {
    "reorderOrder": {
      "success": false,
      "message": "No items were added to cart. All items are out of stock or unavailable.",
      "orderId": 5,
      "itemsAddedCount": 0
    }
  }
}

Cause: All items in the order are out of stock, discontinued, or unavailable

Solution: Check product availability. Some items may have been discontinued or removed from the catalog.

Unauthenticated Request

json
{
  "errors": [
    {
      "message": "Unauthenticated",
      "extensions": {
        "category": "authentication"
      }
    }
  ]
}

Cause: Missing or invalid Bearer token

Solution: Login and provide a valid customer authentication token

Use Cases

Quick Replenishment

Customer frequently reorders the same items:

graphql
mutation {
  createReorderOrder(input: { orderId: 5 }) {
    reorderOrder {
      success
      message
      itemsAddedCount
    }
  }
}

Result: 3 items (coffee, tea, sugar) added to cart in one click

Check Availability Before Purchase

graphql
query {
  order(id: 42) {
    id
    items {
      productId
      name
      quantity
    }
  }
}

mutation {
  createReorderOrder(input: { orderId: 42 }) {
    reorderOrder {
      itemsAddedCount
    }
  }
}

Then proceed to checkout if itemsAddedCount > 0

Reorder with Cart Updates

Customer adds new items, then reorders previous favorites:

graphql
mutation {
  addToCart(input: { productId: 10, quantity: 2 }) {
    success
  }
  
  createReorderOrder(input: { orderId: 15 }) {
    reorderOrder {
      success
      itemsAddedCount
    }
  }
}

Result: New items + previously ordered items in single cart

Notes

  • Order Status Agnostic: Items can be reordered from any order status (pending, completed, shipped, canceled, etc.)
  • Partial Reorder: If some items are unavailable, operation succeeds with those available
  • Pricing Update: Current prices from the catalog are used (not original order prices)
  • Inventory Decremented: Reordered items follow normal inventory management rules
  • No Special Pricing: Promotions/discounts from original order are not automatically applied
  • Customer Isolation: Customers cannot reorder other customers' orders
  • Localization: All messages are localized to the customer's language
  • Bundled Products: Bundles and configurable products are handled gracefully

Implementation Details

Reorder Behavior

Item TypeBehavior
Simple productAdded with same quantity
Configurable productAdded with same options/attributes
Bundle productAdded with same bundle configuration
Grouped productAdded with same selections
Out of stockSilently skipped, not added
DiscontinuedSilently skipped, not added
Not purchasableSilently skipped, not added

Inventory Management

  • Reordered items consume inventory normally
  • Stock is reserved for the active cart
  • No special reservation or hold period
  • Stock can run out between reorder and checkout

Released under the MIT License.