Orders
Authenticated order listing and public detail retrieval with an ID and identifier.
Module role in sales flow
orders provides authenticated order history and public order detail access using an ID and identifier.
- Use this module for order history and order detail pages after checkout.
- For guest checkout completion, immediate order data comes from
payments.initialize()whenaction === 'show_order'oraction === 'pending'. - After user login, use
orders.listfor order history. Useorders.getwith the order's ID andorderIdentifierfor detail retrieval; login is not required for this public lookup.
These methods return the account Order contract. Payment completion returns a
separate CheckoutOrder. Account
items remain InvoiceItem[]; existing account fixtures do not need checkout totals.
Order invoice items keep the same attributes shape as invoice items. Rich
color values expose the display label in value.value and the color payload
(usually a hex string) in value.extra when fieldType is 'color'.
Methods
List
Use: orders.list(filters?, options?).
Requires authentication.
| Field | Type | Required | Description |
|---|---|---|---|
filters.pageNumber | number | Optional | Page number (default 1). |
filters.pageSize | number | Optional | Page size (default 20). |
filters.filters | Array<{ name: string; value: any }> | Optional | Order filters (for example self_only). |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<OrdersListResponse>.
const ordersRes = await client.orders.list({
pageNumber: 1,
pageSize: 20,
filters: [{ name: 'self_only', value: true }],
});Get
Use: orders.get(orderId, orderIdentifier, options?).
Both credentials are required, including for signed-in users. Keep the order identifier private and pass it with the order ID when retrieving an order.
| Parameter | Type | Required | Description |
|---|---|---|---|
orderId | number | string | Required | Order ID. |
orderIdentifier | string | Required | The order's orderIdentifier token. |
options | RequestOptions | Optional | Per-request controls. |
Returns: SazitoResponse<Order>.
const ordersRes = await client.orders.list({ pageNumber: 1, pageSize: 1 });
const firstOrder = ordersRes.data?.orders?.[0];
if (firstOrder) {
const orderRes = await client.orders.get(firstOrder.id, firstOrder.orderIdentifier);
}Migration: replace orders.get(id, options?) with
orders.get(id, orderIdentifier, options?). ID-only calls are no longer supported.
Order key fields
| Field | Type | Required | Description |
|---|---|---|---|
id | number | Required | Account order ID. |
orderNumber | string | Required | Human-readable account order number. |
orderIdentifier | string | Required | Stable order identifier token. |
invoice.netTotal | number | Optional | Invoice total when provided. |
invoice.finalTotal | number | Optional | Final total when provided. |
invoice.invoiceItems | InvoiceItem[] | Required | Account items with id, attributes, quantity, unitPrice, lineTotal, and rawPrice. |
invoice.shippingItems | JsonObject[] | Required | Account shipping assignments. |
Known errors
| Type | When it happens |
|---|---|
validation | Missing/invalid order ID or missing/blank order identifier; no request is sent. |
api | Missing/invalid authentication for listing, or an inaccessible order / mismatched identifier for detail retrieval. |
Examples
// app/lib/sazito-client.ts
import { createSazitoClient } from '@sazito/client-sdk';
export const sazito = createSazitoClient({
domain: process.env.NEXT_PUBLIC_SAZITO_DOMAIN!,
});// app/[lang]/(home)/page.tsx
'use client';
import { useEffect, useState } from 'react';
import { sazito } from '@/app/lib/sazito-client';
export default function Example() {
const [data, setData] = useState<any>(null);
useEffect(() => {
sazito.orders.list({ pageNumber: 1, pageSize: 20 }).then((res) => setData(res.data ?? null));
}, []);
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}Type Details
The following tables are generated from SDK TypeScript types and include nested object fields.
OrderFilters
Source: src/types/order.ts
| Field | Type | Required |
|---|---|---|
pageNumber | number | Optional |
pageSize | number | Optional |
filters | Array<{ name: string; value: JsonValue }> | Optional |
filters.[].name | string | Required |
filters.[].value | JsonValue | Required |
Order
Source: src/types/order.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
orderNumber | string | Required |
orderIdentifier | string | Required |
invoice | OrderInvoice | Required |
OrderInvoice
Source: src/types/order.ts
| Field | Type | Required |
|---|---|---|
invoiceItems | InvoiceItem[] | Required |
shippingItems | JsonObject[] | Required |
netTotal | number | Optional |
finalTotal | number | Optional |
shippingTotal | number | Optional |
discountTotal | number | Optional |
creditTotal | number | Optional |
vat | number | Optional |
vatPercent | number | Optional |
itemsTotalRawPrice | number | Optional |
itemsDiscount | number | Optional |
customerProfit | number | Optional |
customerProfitPercentage | number | Optional |
discountUsages | Array<{ discountCode?: { code?: string }; }> | Optional |
discountUsages.[].discountCode | { code?: string } | Optional |
discountUsages.[].discountCode.code | string | Optional |
InvoiceItem
Source: src/types/invoice.ts
| Field | Type | Required |
|---|---|---|
id | number | string | Required |
productVariantId | number | Required |
productId | number | Optional |
name | string | Required |
url | string | Optional |
attributes | ProductAttribute[] | Required |
productType | string | Optional |
hasMaxOrder | boolean | Optional |
maxOrderQuantity | number | Optional |
minOrderQuantity | number | Optional |
image | Image | Optional |
quantity | number | Required |
unitPrice | number | Required |
lineTotal | number | Required |
rawPrice | number | Required |
customerProfit | number | Required |
commercialFiles | JsonValue | Optional |
formAttributes | Record<string, FormAttributeValue> | InvoiceItemFormAttributes | Optional |
bookingAttributes | SchedulerBookingAttributes | Optional |
formFields | JsonObject | Optional |
ProductAttribute
Source: src/types/common.ts
| Field | Type | Required |
|---|---|---|
name | string | Required |
value | string | ProductAttributeValueObject | Required |
ProductAttributeValueObject
Source: src/types/common.ts
| Field | Type | Required |
|---|---|---|
value | string | Required |
extra | string | Optional |
fieldType | string | Optional |
ShippingAddress
Source: src/types/invoice.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
identifier | string | Required |
firstName | string | Required |
lastName | string | Required |
mobilePhone | string | Optional |
phoneNumber | string | Optional |
email | string | Optional |
region | ShippingAddressRegion | Optional |
city | ShippingAddressCity | Required |
address | string | Required |
postalCode | string | Optional |
description | string | Optional |
latitude | number | Optional |
longitude | number | Optional |
userSetCoordinatesBefore | boolean | Optional |
PaymentMethod
Source: src/types/payment.ts
| Field | Type | Required |
|---|---|---|
id | number | Required |
code | PaymentGateway | Required |
title | string | Required |
titleFa | string | Required |
description | string | null | Required |
paymentSubType | number | null | Required |
order | number | Required |
isDefault | boolean | Required |