# Order Management

## What It Is

The **«Orders»** tab in the **Products** section (`/app/products?tab=orders`) serves as your operations command center for customer purchases. Here you can track, search, filter, and modify orders from all connected bots, print official receipts, and analyze repeat purchasing trends.

## Order Registry

The order table presents all essential order metrics:
- **Order ID**: unique identifier for the transaction.
- **Date & Time**: timestamp when the checkout was finalized.
- **Customer**: buyer name, contact phone/email, direct link to the live chat thread, and customer profile.
- **Line Items**: list of purchased products, quantities, thumbnails, and SKUs.
- **Total Amount**: final sum accounting for discounts, shipping fees, and taxes.
- **Status**: current order processing state.

### Order Status Lifecycle

The system tracks orders through 5 standard lifecycle phases:

| Status | Code | Description |
|---|---|---|
| **New** | `0` | Just submitted by the customer; awaiting merchant review |
| **Processing** | `1` | Order confirmed; warehouse begins fulfillment (stock is reserved) |
| **Paid** | `2` | Payment verified (online checkout or payment on delivery) |
| **Delivered** | `3` | Successfully handed over to customer or picked up |
| **Cancelled** | `4` | Order rejected or cancelled (reserved inventory is restored) |

Changing an order status can automatically trigger a custom customer notification on Telegram (see [Custom Status Notifications](Custom%20Status%20Notifications.md)).

## Order Details & Line Item Editing

Clicking any order row slides out the detailed order inspector:
- **Adjust Quantities**: increment or decrement the unit count for each item.
- **Add Products**: add extra items directly from the catalog if a customer requests additions after placing the order.
- **Remove Items**: delete individual positions from the cart.
- **Automatic Recalculation**: any modification to order items automatically recalculates subtotals, applied discount percentages, shipping costs, taxes, and the final order total (`summa`).

## Branded PDF Invoices & Receipts

Every order features one-click generation of professional sales receipts formatted for print and digital delivery:

1. Click the **«Receipt PDF»** button in the order drawer.
2. The platform renders a branded PDF containing:
   - **Bot logo and title**.
   - **Company business credentials** (from the bot's business profile).
   - **Customer details and shipping destination**.
   - **Itemized goods table**: SKU, item title, unit price, quantity, and total.
   - **VAT/Tax, discount, and shipping fee calculations**.
   - **Customized receipt footer note** (configured in Settings).

PDFs are generated instantly and optimized for standard A4 printing or direct attachment in customer chats.

## Customer Cohorts & Retention Analytics

The **«Cohorts»** tab delivers actionable customer intelligence:
- **Purchase Frequency Breakdown**: segmenting your buyer audience:
  - *1 order*: first-time purchasers;
  - *2 orders*: returning customers;
  - *3+ orders*: loyal core advocates.
- **Average Order Value (AOV)** and average orders per buyer.
- **Customer Profiles**: select any buyer to inspect their lifetime spending history, frequency, and chronological order records.
