Order History & Tracking
The Orders API provides shoppers with full transparency into their purchase history. Every order includes an immutable snapshot of items and a real-time fulfillment timeline, allowing you to build professional post-purchase experiences.
The Shopper Journey
- 1Authentication: All order requests require the
X-Customer-Tokento ensure privacy. - 2Overview: Fetch a paginated list of orders for the account dashboard.
- 3Deep Dive: Retrieve full details including tracking numbers and line-item snapshots.
01. List My Orders
Returns a reverse-chronological list of orders. This endpoint is optimized for high-speed "Account Overview" pages by excluding heavy address and item metadata.
GET /v1/orders
QUERY PARAMS- page (integer)Optional. The page number. Defaults to 1.
- limit (integer)Optional. Number of orders (max 50). Defaults to 10.
const getMyOrders = async (page = 1) => {
const res = await fetch(`https://api.electivecommerce.com/v1/orders?page=${page}&limit=10`, {
method: 'GET',
headers: {
'Authorization': 'Bearer pk_live_...',
'X-Customer-Token': localStorage.getItem('shopper_token')
}
});
const { success, data, meta } = await res.json();
if (success) {
// Returns basic summary: id, status, total, created_at
return data;
}
};02. Order Details & Tracking
Retrieves the complete state of an order. This includes the product titles and prices at the time of purchase, both shipping and billing addresses, and the history events (e.g., when the package was shipped).
GET /v1/orders/:id
PATH PARAM- id (uuid)Required. The unique identifier of the order.
Response Schema highlights
- items: Array of product snapshots.
- history: Timeline of fulfillment status changes.
- tax / shipping: Final costs applied to order.
const getOrderDetail = async (orderId) => {
const res = await fetch(`https://api.electivecommerce.com/v1/orders/${orderId}`, {
method: 'GET',
headers: {
'Authorization': 'Bearer pk_live_...',
'X-Customer-Token': localStorage.getItem('shopper_token')
}
});
const { success, data } = await res.json();
if (success) {
console.log('Items Snapshot:', data.items);
console.log('Shipping to:', data.shipping_address.city);
console.log('History:', data.history); // Timeline events
}
};Understanding Snapshots
Elective Commerce ensures data integrity by storing an immutable snapshot of every product variant in the order. If you change a product's price from $50 to $60 in the dashboard, any order placed before that change will still correctly reflect $50.
| Status Column | Possible Values | Meaning |
|---|---|---|
| status | pending, processing, completed, cancelled | The high-level lifecycle stage of the transaction. |
| payment_status | unpaid, paid, refunded | The financial state as confirmed by the payment gateway. |
| fulfillment_status | unfulfilled, partial, fulfilled | Indicates if the physical or digital goods have been shipped. |
