> ## Documentation Index
> Fetch the complete documentation index at: https://developer.lulacommerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Patch Order Cart

> Modify order items by adding, removing, or updating quantities after order creation but before completion.

This endpoint allows you to modify order contents after the order has been created but before it's completed. You can remove items, reduce quantities, add new items, or update existing items. This is useful for handling out-of-stock situations, customer requests, or inventory adjustments.

<Warning>
  Order modifications should only be made with customer approval and may affect the final order price. Always communicate changes to the customer.
</Warning>

### Path Parameters

<ParamField path="order_id" type="string" required>
  The unique identifier of the order to modify
</ParamField>

### Request Body

The request body should be an array of action objects, each specifying a modification to perform:

<ParamField body="action_type" type="string" required>
  Type of modification: "remove\_item", "reduce\_quantity", "add\_item", "update\_item"
</ParamField>

<ParamField body="order_item_id" type="string" required>
  The unique identifier of the order item to modify (required for remove\_item, reduce\_quantity, update\_item)
</ParamField>

<ParamField body="quantity" type="integer" optional>
  New quantity for the item (required for reduce\_quantity and add\_item actions)
</ParamField>

<ParamField body="item_id" type="string" optional>
  Product identifier (required for add\_item actions)
</ParamField>

<ParamField body="special_instructions" type="string" optional>
  Updated special instructions for the item
</ParamField>

### Response

<ResponseField name="id" type="string">
  Updated order identifier
</ResponseField>

<ResponseField name="original_subtotal" type="string">
  Updated order subtotal after modifications
</ResponseField>

<ResponseField name="tax_amount" type="string">
  Recalculated tax amount
</ResponseField>

<ResponseField name="original_price" type="string">
  Updated original price
</ResponseField>

<ResponseField name="partner" type="string">
  Delivery platform name
</ResponseField>

<ResponseField name="special_instructions" type="string">
  Order-level special instructions
</ResponseField>

<ResponseField name="customer" type="object">
  Customer information remains unchanged
</ResponseField>

<ResponseField name="fulfillments" type="array">
  Updated fulfillment information with modification logs

  <Expandable title="Fulfillment Details">
    <ResponseField name="fulfillmentsLogs" type="array">
      Complete log of all order changes including modifications

      <Expandable title="Fulfillment Log Entry">
        <ResponseField name="date_created" type="string">Timestamp of the modification</ResponseField>
        <ResponseField name="description" type="string">Description of what was changed</ResponseField>
        <ResponseField name="order_status_title" type="string">Status title (e.g., "Item quantity edited")</ResponseField>
        <ResponseField name="employee" type="object">Employee who made the modification</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="orderItems" type="array">
  Updated array of order items after modifications
</ResponseField>

### Request Example

```json theme={null}
[
  {
    "action_type": "remove_item",
    "order_item_id": "35bf2e22-a70f-4dda-9de0-eb92ee581d4a"
  },
  {
    "action_type": "reduce_quantity",
    "order_item_id": "3133710b-6d3e-4533-8d67-26c7a4a93e29",
    "quantity": 2
  }
]
```

### Response Example

```json theme={null}
{
  "id": "a8e2c9ee-0bbd-4e86-ab2c-40e94297b3bd",
  "original_subtotal": "-35.26",
  "is_auto_accepted": false,
  "order_id": null,
  "tax_amount": "NaN",
  "discount": null,
  "original_price": null,
  "createdAt": "2024-07-04T12:06:57.740Z",
  "partner": "DoorDash",
  "special_instructions": "Cancel the order if the first item is not Present",
  "exclude_allergens_items": "",
  "is_include_disposables": false,
  "store_id": "449235c1-3d04-4519-998b-40d2a621e5e0",
  "dsp_order_number": "",
  "custom_fee": null,
  "tax_remitted": "NaN",
  "customer": {
    "customer_name": "Lula D.",
    "contact_phone": "+1 312-766-6835",
    "phone_code": null
  },
  "fulfillments": [
    {
      "quantity": null,
      "date_ready": null,
      "createdAt": "2024-07-04T12:06:57.756Z",
      "estimated_date_delivered": "2024-07-04T12:17:14.540Z",
      "id": "2f71af29-e115-42f1-839f-1137efa73c8a",
      "store_id": "449235c1-3d04-4519-998b-40d2a621e5e0",
      "fulfillmentStatus": {
        "delivery_status_name": "waiting"
      },
      "fulfillmentsLogs": [
        {
          "date_created": "2024-07-04T12:06:57.758Z",
          "description": "DoorDash store mock order received",
          "order_status_title": "Order received",
          "fulfillments_id": "2f71af29-e115-42f1-839f-1137efa73c8a",
          "employee": null
        },
        {
          "date_created": "2024-07-04T12:07:14.577Z",
          "description": "",
          "order_status_title": "Bagging order",
          "fulfillments_id": "2f71af29-e115-42f1-839f-1137efa73c8a",
          "employee": {
            "id": "f78c06a0-8a0f-4d0b-a5d1-d7d2b0ffde70",
            "first_name": "Salman",
            "last_name": "Saeed Paul"
          }
        },
        {
          "date_created": "2024-07-04T12:07:56.205Z",
          "description": "Removing [1] 'Cheetos Flamin' Hot Cheese Flavored Snacks'.",
          "order_status_title": "Item quantity edited",
          "fulfillments_id": "2f71af29-e115-42f1-839f-1137efa73c8a",
          "employee": {
            "id": "f78c06a0-8a0f-4d0b-a5d1-d7d2b0ffde70",
            "first_name": "Salman",
            "last_name": "Saeed Paul"
          }
        }
      ]
    }
  ],
  "orderItems": []
}
```

<Accordion title="Available Action Types">
  **remove\_item**

  * Completely removes an item from the order
  * Requires: order\_item\_id
  * Use when item is out of stock or customer requests removal

  **reduce\_quantity**

  * Reduces the quantity of an existing item
  * Requires: order\_item\_id, quantity (new quantity, not amount to reduce)
  * Use for partial availability or customer quantity changes

  **add\_item**

  * Adds a new item to the order
  * Requires: item\_id, quantity
  * Optional: special\_instructions
  * Use for customer additions or substitutions

  **update\_item**

  * Updates item details without changing quantity
  * Requires: order\_item\_id
  * Optional: special\_instructions, item modifications
  * Use for customization changes
</Accordion>

<Note>
  **Price Recalculation**: The system automatically recalculates taxes, fees, and total price after modifications. Negative subtotals in the response indicate cost reductions.
</Note>

<Tip>
  **Best Practice**: Always batch multiple modifications into a single request to avoid multiple price recalculations and to maintain order consistency.
</Tip>

### Error Responses

<Accordion title="Common Error Scenarios">
  **Invalid Order Item**

  ```json theme={null}
  {
    "error": "Order item not found",
    "order_item_id": "invalid-id"
  }
  ```

  **Order Not Modifiable**

  ```json theme={null}
  {
    "error": "Order cannot be modified in current status",
    "current_status": "completed"
  }
  ```

  **Invalid Quantity**

  ```json theme={null}
  {
    "error": "Quantity must be greater than 0",
    "provided_quantity": 0
  }
  ```
</Accordion>

<Warning>
  **Status Restrictions**: Orders can only be modified in certain statuses (pending, accepted, in\_progress). Completed, canceled, or delivered orders cannot be modified.
</Warning>

### Use Cases

<Accordion title="Common Modification Scenarios">
  **Out of Stock Items**

  * Remove unavailable items
  * Reduce quantities for partial availability
  * Add substitute items with customer approval

  **Customer Requests**

  * Add items to existing order
  * Remove items customer no longer wants
  * Modify special instructions

  **Inventory Adjustments**

  * Reduce quantities when stock is lower than expected
  * Remove items due to quality issues
  * Update item specifications

  **Price Corrections**

  * Adjust item quantities for pricing corrections
  * Remove incorrectly priced items
  * Add corrected items
</Accordion>
