TABLE OF CONTENTS
- Overview
- How the Three Numbers Relate
- From Add-to-Cart to Order Confirmation
- Data Flow by Stage
- Example: Wrong Order Total
- Golden Rules
- Troubleshooting
Solution Architecture Guidance
Separate Lifecycle Records
Treat cart, checkout and order as separate lifecycle records rather than one record that changes status. Each transition creates a new identifier, so requirements involving cross-stage reporting, integrations, troubleshooting or continuity must account for how data is copied and related across the stages.
Not every transaction goes through all three stages:
- Approval-required orders go through an extra pending-approval record, with its own number, and only become an order once approved.
- Quote-based orders go from cart to quote to order, without a checkout.
The platform does not store a link between the cart, checkout and order numbers. If cross-stage reporting or tracing is a requirement, that link needs to be captured explicitly as part of the solution.
Transaction Paths
Evaluate checkout changes across every applicable transaction path. Offline and zero-total orders, approval flows, online payments and quote-to-order conversion do not all follow the same route, even though they ultimately create an order. A customization implemented for only one path can produce inconsistent data or behavior in another.
Approval and online payment can also apply to the same order: the payment is authorized at checkout, captured when the order is approved, and voided if it is rejected.
Order as the Authoritative Record
Preserve the order as the authoritative record after placement. Requirements for receipts, order history, returns, payment reconciliation or downstream integrations should be based on order data, while abandoned or failed checkout investigation may depend on operational logs rather than an administrator-visible record. Two qualifications apply:
- Before approval, the pending-approval record is the authoritative record, because no order exists yet.
- For online payments, the payment is authorized before the order is created. Payment reconciliation should therefore use the payment gateway's transaction history alongside the order data. If an order fails after payment, the system voids or refunds the payment automatically, and that is recorded in the logs.
Project-Specific Checkout Data
Requirements that add project-specific data to checkout can affect more than the checkout experience, because that data may need to persist into the placed order and support downstream uses such as order history, reporting, approvals or integrations. The greater the number of transaction paths and downstream uses involved, the greater the implementation, testing and support scope.
Project-specific data is stored in a small number of shared custom-data slots, and two of them are already in use: one for checkout custom fields and approval manager details, and one for approver comments. Any new requirement must be designed so it doesn't overwrite existing data.
Overview
A cart, a checkout and an order are three separate records in Znode, each with its own number. This guide traces exactly what data moves between them, what shape it takes, and where to look when a value is wrong.
- Product: Znode 10 storefront
- For: implementation partners and developers
- Companion to: the checkout workflow guide
- Focus: data shapes, storage, debugging — not UI
Three records, three numbers. Nothing is renamed in place — each arrow mints a brand-new class number in a different collection.

| Collection | Number | Description |
|---|---|---|
| Carts | cartNumber | Created on first add-to-cart; lives in a cookie for guests. |
| Checkout | checkoutNumber | A copy of the cart; never a cookie, always encrypted in sessionStorage. |
| Orders | orderNumber | The permanent record once payment and placement succeed. |
How the Three Numbers Relate
A trap worth knowing before you read any checkout code: several checkout and payment data shapes have a field literally called cartNumber that, once checkout has started, actually holds the checkout number. The storefront server always re-derives the real checkout number from the encrypted session header before using it — it never trusts the field name or the browser's value.

The field name survives across the type system (IPaymentRequest.cartNumber, createOrder's cartNumber argument), but by the time it reaches placeOrder it is the checkout class number — the value re-derived server side from x-checkout-ref, not whatever the browser sent.
| Transition | Trigger | Call | New number lands in |
|---|---|---|---|
| Cart created | First add-to-cart | Carts_addToCart | IAddToCartResponse.cartNumber |
| Cart → Checkout | Shopper clicks Checkout | CommerceCollections_copy("Carts", cartNumber, "Checkout", origin) | encrypted into sessionStorage["_zn_tref"] |
| Checkout → Orders (offline / zero total / approval) | Place order submit | CommerceCollections_placeOrder("Checkout", checkoutNumber, payload) | IConvertedToOrderResponse.orderNumber |
| Checkout → Orders (online payment) | Card / ACH / wallet submit | CommerceCollections_generateFinalizeNumber reserves the number, then the same placeOrder call | finalClassNumber, then orderNumber |
| Quote → Order | Approved quote converted | placeOrderFromQuote → CommerceCollections_placeOrder("quotes", ...) | orderNumber, no checkout session involved |
From Add-to-Cart to Order Confirmation
Solid arrows are requests, dashed arrows are responses. The browser never computes a total or sees the real checkout number in plain text — every amount shown on screen is re-read from the server on the next step.

Offline and zero-total orders skip steps 6–8 and call /api/place-order directly with the same effect: a validated placeOrder call against the checkout number.
Data Flow by Stage
Stage 1 - The Cart Stage
A cart holds line items and nothing about payment. Guests carry their cart number in a cookie; logged-in users have it looked up by user ID. When a guest logs in mid-shop, the two carts are merged into a third, new cart number — not either of the originals.
| Data | Agent | Shape |
|---|---|---|
| Line items | getCartItems(cartNumber) | ICart — cartItems[] with sku, quantity, unitPrice, totalPrice, attributes, add-ons |
| Totals and discounts | getCartSummary(cartNumber, isCart, ...) | ICartSummary — subTotal, total, shippingCost, taxCost, discounts[], costs[] |
| Guest → logged-in merge | mergeGuestUserCart | Carts_mergeCart → MergedCartNumber (a new cart number) |
Note: getCartItems accepts a classType parameter and is reused later, unchanged, against "Checkout" and "Orders" — all three collections share the same item-list shape on the back end, which is why one function reads line items at every stage.
Stage 2 - Cart to Checkout: The Session Handoff
Checkout runs on a copy of the cart so the cart stays intact while the shopper pays, and each browser tab gets an independent session. The full extension-point discussion for this mechanism is in the checkout workflow guide; here is exactly what data moves.
STEP 1 - Copy the cart
POST /api/cart/copy-to-checkout reads cartNumber from the cookie and calls CommerceCollections_copy("Carts", cartNumber, "Checkout", origin). A new Checkout row is created with its own checkoutNumber; the cart row is untouched.
STEP 2 - Encrypt the reference
The route encrypts checkoutNumber with AES-GCM and returns { checkoutRef, serverNow }. This is the only form the checkout number ever takes outside the back end and a decrypted server request.
STEP 3 - Store it per tab
The browser saves checkoutRef in sessionStorage under _zn_tref — never a cookie, so one tab cannot see or clobber another tab's checkout.
STEP 4 - Attach it to every call
The shared httpRequest helper adds it as the x-checkout-ref header automatically on checkout calls. A route that forgets to call through httpRequest will never receive it.
STEP 5 - Decrypt and validate on the server
getCheckoutNumberFromRequest(request) decrypts the header (empty string if missing or tampered). validateCheckout(checkoutNumber) reports ACTIVE, INACTIVE, EXPIRED or NOT_FOUND — copying the cart again invalidates any earlier checkout for that cart.
Reliable: the checkout number is never readable in a URL, cookie, or page source — only a decrypted server request ever sees it in plain text.
Watch for: a direct visit to /checkout with no _zn_tref set sends the shopper back to the cart — this is expected, not a bug.
Stage 3 - The Checkout Stage: Where Each Piece Lands
Every write during checkout is keyed by the checkout number, not the cart number. Totals are re-read from the server on every step — the browser is never the source of truth for money.
| Data | Written by | Znode call |
|---|---|---|
| Shipping / billing address | updateAddressIds | Shippings_shippingAddress + Payments_payments, both keyed by checkoutNumber |
| Shipping method | updateShippingDetails | Shippings_orderShipment({ classNumber: checkoutNumber, shippingId, ... }) |
| Discounts / vouchers | applyDiscount (isCheckout: true) | recalculated through the same getCartSummary path as the cart page |
| Totals shown on review | — (read-only) | getCartSummary(checkoutNumber, false, ...) |
| Custom checkout data (project-specific fields, approval routing, vouchers) | placeOrder, before the order is placed | Order_updateOrderDetails({ endpoint: "carts", orderPayload: { classNumber: checkoutNumber, customData: { custom1: JSON.stringify(data) } } }) |
Important: custom checkout data is a JSON string inside customData.custom1 (or custom2–custom5), not a separate column. Each write replaces that slot entirely — two features writing the same slot will overwrite each other. If a custom value "isn't showing up," check for a second write clobbering it or a stringify/parse mismatch before assuming the feature itself is broken.
Two Submit Paths, One Choke Point
| Path | Payload type | Route | Converges on |
|---|---|---|---|
| Offline payment, zero total, approval | IConvertToOrder | POST /api/place-order, /api/submit-for-approval | placeOrder(convertToOrderRequestModel, checkoutNumber) |
| Online payment (card, ACH, wallets, APM) | IPaymentRequest | PUT /api/place-order/finalize-number then POST /api/payment-manager/create |
Both payloads carry the same underlying data in two different shapes. placeOrder in the checkout agent is the single point every path passes through before CommerceCollections_placeOrder runs — it is also where the server-side total check lives:
packages/agents/src/checkout/checkout.ts (placeOrder)
if (!paymentDetails.configurationSetCode) {
const cartSummary = await getCartSummary(checkoutNumber); // checkoutNumber, read from the server
if (cartSummary?.orderTotalWithoutVoucher > 0) {
return { isSuccess: false }; // refuse a "free" order that isn't actually free
}
}Stage 4 - Checkout to Order, and Reading It Back
CommerceCollections_placeOrder("Checkout", checkoutNumber, payload) returns the order number and the payment outcome in one response. From here on, the order number is the only key that matters — receipts, order history, returns and payment capture all key off it, never the checkout number.
| Field on the order row | What it holds |
|---|---|
| Total, SubTotal | Direct columns |
| CostFactorResponse[] | An array of { Name, Value } pairs — TaxCost, ShippingCost, HandlingFee, CSRDiscount, TotalDiscount, ImportDuty are all read out of here by name |
| LineItemDetails | Line items, mapped the same way as cart line items |
| PaymentDetails | paymentSubTypeCode, configurationSetCode, RemainingOrderAmount for partial/invoice payments |
| CustomData.custom1 / custom2 | JSON-stringified project-specific checkout data, carried over from the checkout row |
Payment gateway transaction history (authorize / capture / void events) is a separate call, Payments_paymentTransactionHistoryByClassNumber(orderNumber) — it is not part of the order row itself.
Data Storage Across Stages
| Data | Browser / session | Cart | Checkout | Order |
|---|---|---|---|---|
| Identifier | CartNumber cookie | cartNumber | checkoutNumber, encrypted in sessionStorage only | orderNumber, briefly in a cookie for the receipt |
| Line items | render state only | ICartItem[] | same shape, keyed by checkoutNumber | LineItemDetails |
| Shipping address | in-memory until submit | guest snapshot in localStorage only | Shippings_shippingAddress row | IAddress flagged isShipping |
| Billing address | same | — | Payments_payments row | IAddress flagged isBilling |
| Payment method | component state until submit | — | resolved at submit, not stored mid-checkout | PaymentDetails.configurationSetCode |
| Totals / discounts | never computed client-side | ICartSummary | ICartSummary, same shape | Total, SubTotal, CostFactorResponse[] |
| Custom checkout data | form state | — | CustomData.custom1/custom2 (JSON) | same slot, carried over |
Example: Wrong Order Total
STEP 1 - Get the order number
From the receipt email, or Znode Admin → Orders if you only have a date or email address.
STEP 2 - Pull the order row
In Admin, or via getOrder(orderNumber) in code — both read CommerceCollections_classDetailsByClassType("Orders", orderNumber).
STEP 3 - Read the cost breakdown, not just the total
Check each entry in CostFactorResponse (TaxCost, ShippingCost, HandlingFee, CSRDiscount, TotalDiscount, ImportDuty) against what the customer expected. A wrong total is almost always one factor, not the subtotal.
STEP 4 - Check custom data for pricing inputs
If the store has a project-specific pricing rule (a voucher, an approval discount, a negotiated rate), parse CustomData.custom1/custom2 — this often shows whether the rule fired with the wrong input, versus not firing at all.
STEP 5 - Compare against the actual payment
Payments_paymentTransactionHistoryByClassNumber(orderNumber) shows what the gateway actually authorized and captured. A mismatch against Total here points at a gateway-side rounding or currency issue, not storefront logic — the storefront always reads totals server-side before charging.
STEP 6 - If it looks pre-order, check the logs
The checkout row itself may already be superseded once an order exists. Server logs under Webstore_Checkout and Webstore_Cart around the order's timestamp show the cart/checkout summary calls and discount applications, including which checkout number was involved.
STEP 7 - Last resort: a custom rule
Search the project's own checkout customization folder for anything that recalculates or overrides a cost factor outside getCartSummary.
| Log area | Covers |
|---|---|
| Webstore_Cart | Add to cart, cart summary, merge, item mutations |
| Webstore_Checkout | Checkout session, address/shipping updates, placeOrder, validateCheckout |
| Webstore_Payment | createPayment, gateway calls, payment-manager routes |
| Webstore_Order | Order placement result handling, refund/void on failure |
Admin shows the placed order's line items, addresses, payment status, cost factors and custom data — the same row the storefront reads.
Admin does not show an abandoned checkout's sessionStorage state or the encrypted checkout reference. For those, use server logs filtered by area, and the browser's own storage/network tab if you can reproduce it.
Golden Rules
| Rule | Details |
|---|---|
| Three numbers, not one | cartNumber, checkoutNumber and orderNumber are different values in different collections, minted fresh at each transition. |
| cartNumber can lie | On checkout and payment types, a field called cartNumber may actually carry the checkout number — the server always re-derives the real one. |
| Money is never client-side | Every total used to place an order or charge a payment is re-read from getCartSummary on the server. |
| Custom data lives in one JSON slot | customData.custom1–5 hold stringified project data; each write replaces the whole slot. |
| The checkout number never leaves the server in plain text | Only sessionStorage (encrypted) and a decrypted server request ever hold it. |
| Once an order exists, it is the record | The checkout row that produced it may already be superseded — debug from the order outward, not the checkout. |
Troubleshooting
| You see | What it usually means |
|---|---|
| Order total doesn't match what the cart showed | Check CostFactorResponse on the order, not just Total — a discount, tax or shipping factor differs from the cart-page estimate |
| Custom checkout field missing from the order | Another write replaced the customData slot, or the field was added to only one of the two submit paths (offline vs. online payment) |
| Checkout session keeps expiring | No _zn_tref in sessionStorage (direct visit), another tab replaced it, or the timer setting is too short |
| "cartNumber" in a checkout log line looks like a checkout number | It is — that field is overloaded after checkout starts; confirm against the encrypted header, not the field name |
| Payment succeeded but no order appeared | Check Webstore_Order logs for a refund/void — placeOrder releases a successful payment automatically when the order itself fails to place |
| Guest's cart items vanished after login | Expected if the login-time merge produced a different MergedCartNumber than either input cart |