# Order edit: "Remove" now cancels the product (app update)

**For:** mobile app developer · **Date:** 2026-10-21 · **Branch:** `fix/order-edit-cancel-line-2026-10-21`

No breaking change: no endpoint, URL or request body changed. Two fields were **added** and one behaviour changed.

## 1. The change

On the order edit screen, **إزالة / Remove** on a product used to **delete** it from the order. Now it **cancels** it:

- the product stays in the order with `delivery_status: "cancelled"`;
- it is shown struck through with a **"ملغى"** badge;
- it is in **no** total (the server's totals already exclude it);
- it is final: it can't be edited again and never comes back.

Products removed before this change were deleted and do not appear.

## 2. API

### `GET /api/v2/purchase-history/combined/{order_id}`

- `orders[].lines[]` now **includes** cancelled products.
- New field **`lines[].is_cancelled`** (bool): `true` = cancelled by the customer → draw it as cancelled.
- New field **`edit_history[].changes[].cancelled`** (bool).

```json
{
  "id": 7790,
  "product_name": "بنطال جينز",
  "variation": "Blue-32",
  "quantity": 1,
  "price": {"amount": 90000, "formatted": "90,000 ل.س"},
  "delivery_status": "cancelled",
  "is_returned": false,
  "is_cancelled": true
}
```

```json
"changes": [
  {"product": "بنطال جينز", "from": "Blue-32 · الكمية 1", "to": "", "removed": true, "cancelled": true}
]
```

`amount`, `products_count`, `subtotal`, `tax`, `total` already exclude cancelled products. **Never sum `lines` yourself.**

When the **whole** seller order is cancelled, its lines are `cancelled` with `is_cancelled: false` (as before).

### `order-edit` endpoints (open / preview / save)

Unchanged. `{"id": 7790, "remove": true}` now cancels the line (still listed in `removed`). Cancelled products are no longer returned by `GET /api/v2/order-edit/{order_id}`. After saving, reload the order page.

### Old endpoints

- `purchase-history-items/{id}`: a cancelled product is now listed, with `delivery_status: "cancelled"` ("ملغاة").
- `purchase-history-details/{id}`: `subtotal` / `tax` now exclude cancelled products.

## 3. UI

**Cancelled product line** (`is_cancelled: true`):
- image 50% opacity + greyscale, name in grey;
- price struck through;
- red pill **ملغى** (same style as "مرتجع");
- no review / refund / edit buttons.

**Edit history**:

| `removed` | `cancelled` | Show |
|---|---|---|
| `true` | `true` | ألغيته |
| `true` | `false` | حُذف (old deletions) |
| `false` | `false` | `from → to` |

**Edit screen note** (new text):
- AR: يمكنك تغيير كمية المنتج أو خياره، أو إلغاؤه، إلى أن يراجع البائع طلبك.
- EN: You can change the quantity or option of a product, or cancel it. You can do this until the seller reviews your order.

The Remove button itself is unchanged (إزالة / تراجع).

## 4. Quick test

1. Order with A (1 × 10,000) and B (2 × 20,000). Edit → Remove B → Save.
   - B shows struck through with "ملغى".
   - Total = 10,000 (+ shipping); `products_count` = 1.
   - History shows "B: ألغيته".
2. Open edit again → only A is listed.
3. The seller confirms the order → A is confirmed, B stays "ملغى".
