Postman collection
Orders Read

pixiGetOrderHeadersForCustomer

Returns the order headers of a customer, identified by customer key or by external customer number or e-mail, with payment, voucher and shipping data.

Returns one row per order (OrderHeader) of a customer, sorted by OrderDate descending.

Customer selection

  • If CustKey is not 0, only orders with CustRef = CustKey are returned. CustomerNrExternal and ShopID are ignored in this case.
  • If CustKey is 0 (default), orders of all customers whose CustomerNrExternal or e-mail address (CeMail) equals CustomerNrExternal are returned. If ShopID is given, the customer must also belong to that shop (CustomerOf). An empty ShopID is treated as NULL (no shop filter).

Further filters

  • OrderDateFrom: only orders with OrderDate on or after this value. NULL or empty means 1900-01-01.
  • OrderStatus: OPEN, HOLD or CLOSED filters on the order status. Any other value (or NULL) disables the status filter.

Returned data per order

  • Header data such as order number, external order number, totals, ship cost, shop note, address remarks and currency code (OrderCurrencyCode from the currency of the order).
  • Payment data from the payment address (AddrRef): payment type, credit card and bank account fields, ZIP.
  • ShopID is the shop the customer belongs to (CustomerOf).
  • OrderLocked is the lock flag (ASlocked) of the shipping address, N if not set.
  • VoucherID / VoucherAmount: highest voucher ID and highest voucher amount found on the order lines (vouchers referenced by order lines); NULL if the order has no voucher.
  • Shipdate / LastShipdate: earliest and latest scan-out date of all invoices linked to the order lines.
  • TrackingID / ShipVendor: taken from the invoice with the highest InvoiceKey; the tracking ID falls back to the drop-shipment tracking ID of the order line if the invoice has none. NULL if the order has not been invoiced.

Notes

  • All tables are read WITH (NOLOCK); results may contain uncommitted data.
  • If CustKey is 0 and CustomerNrExternal is left empty, the filter matches customers with an empty external customer number or an empty e-mail address. Always pass either CustKey or a non-empty CustomerNrExternal.
  • Because the e-mail address is also matched, several customers (e.g. in different shops) can match; use ShopID to restrict.
  • The intermediate temporary table has unique indexes on OrderNr and AddrRef. If two selected orders share the same payment address or more than one has OrderNr NULL, the call fails with a SQL duplicate-key error.
  • VoucherID and VoucherAmount are aggregated independently with MAX; with several vouchers on one order they may come from different vouchers.
  • If the latest invoice has several lines with different fallback tracking IDs, the selection is not deterministic and an order may in rare cases appear more than once.
  • The result contains sensitive payment data (card number, bank account).

Tables used

OrderHeader · Read Customers · Read Addresses · Read Currency · Read Orderlines · Read Voucher · Read Invlines · Read Invoices · Read
SQL object:
dbo.pipiGetOrderHeadersForCustomer
Updated at 2026-10-30