Bare Necessities
Preorder & Backorder Sync / Architecture & Scenarios
Internal Reference & Architecture

How a preorder becomes a real order

Four scenarios covering how Movex, Barrett, Techsera, Shopify, and STOQ stay in sync — from a purchase order landing in the ERP to customer delivery.

1
Movex
ERP / Source of truth
2
Barrett
Warehouse / Physical
3
Techsera
Integration / Bridge
4
Shopify
Storefront & Holds
5
STOQ
Preorder Limits
Topology & Roles

Who does what across the stack

Each component maintains a strict single responsibility boundary to prevent race conditions and out-of-sync inventory numbers.

ERP

Movex

ERP where purchase orders (POs) originate and expected inventory is created. Has zero concept of Shopify or preorder rules.

Warehouse

Barrett

Physical warehouse. Receives and checks in physical shipment units against open POs.

Integration Layer

Techsera

Integration middleware. Responsible for writing inventory deltas and PO signal triggers into Shopify.

Storefront & Orders

Shopify

Tracks available vs committed stock natively. Holds and releases fulfillment orders on inventory adjustments.

Preorder Engine

STOQ

Decides preorder button eligibility, applies checkout holds, and strictly enforces the customer sell limit.

Scenario 01

New PO arrives in Movex

TRIGGER: PO registered in ERP — zero physical units have arrived yet.
1
MOVEX
PO is created — quantity and expected ship date are recorded. No physical stock exists yet.
2
TECHSERA
Writes the incoming quantity to the variant's backorder.incoming_po_quantity metafield via Shopify's GraphQL API (metafieldsSet) — this value is set/overwritten each time, not accumulated. It exists only to carry this one PO's quantity and trigger the next step.
Shopify — metafieldsSet Mutation
View GraphQL Request Payload
# Definition ID: gid://shopify/MetafieldDefinition/214024749169
mutation SetIncomingPOQuantity($metafields: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $metafields) {
    metafields {
      id
      namespace
      key
      value
      type
    }
    userErrors {
      field
      message
      code
    }
  }
}

# GraphQL Variables:
{
  "metafields": [
    {
      "ownerId": "gid://shopify/ProductVariant/{{variant_id}}",
      "namespace": "backorder",
      "key": "incoming_po_quantity",
      "value": "100",
      "type": "number_integer"
    }
  ]
}
3
SHOPIFY FLOW
Detects the metafield change via the Workflow Trigger Extensions app (Flow has no native metafield-change trigger) and kicks off the read → calculate → write sequence in steps 4–5.
4
STOQ
Current preorder_max_count is read for that variant — the update endpoint sets an absolute value, so the current limit has to be queried first.
STOQ — Read Variant Limit API
5
STOQ
New absolute limit is written: current limit + incoming PO quantity.
STOQ — Update Variant Settings PATCH
Interactive Math Simulator Edit numbers
Current Limit
New PO Qty
180
New STOQ Limit
Result & System State

The preorder limit immediately reflects incoming stock. Physical inventory and order holds are completely untouched at this stage.

The metafield itself is transient — it only exists to trigger this sequence; the real accumulated value lives in STOQ's preorder_max_count.

Scenario 02

Stock arrives, covers preorders & leaves surplus

TRIGGER: Physical stock arrives at Barrett and exceeds held preorders (leaves real surplus inventory).
1
BARRETT
Receives the physical shipment of units into warehouse storage.
2
TECHSERA
Pushes received quantity directly to Shopify as an inventory delta via GraphQL (inventoryAdjustQuantities).
Shopify — inventoryAdjustQuantities Mutation
3
SHOPIFY
Available turns positive natively as inventory increases. Committed does NOT drop automatically — orders stay on hold until explicitly released.
4
SHOPIFY FLOW
Triggered by inventory change (prior <= 0 and current > 0). Queries held fulfillment orders, filters specifically by heldByApp.id (STOQ holds only — never a blanket release to avoid payment holds), and releases them.
Shopify — fulfillmentOrderReleaseHold Mutation
5
STOQ (RECALCULATE)
Because this shipment left surplus units, recalculate the limit: limit = count + units_in_transit − preorders_waiting (or reset count to 0, limit = units_in_transit). Correctly removes surplus units from the preorder quota so they sell as regular stock.
6
STOQ (DISPLAY)
Flips storefront CTA from "Preorder" to "Add to Cart" automatically once available > 0.
Surplus Recalculation Example Confirmed Model
Initial: Limit = 180, Count = 50 (50 preorders held)
Arrival: PO of 100 units arrives (covers 50, leaves 50 surplus)
In-Transit: Only PO#2 (80 units) remains, 0 waiting
New Limit: 50 + 80 − 0 = 130 (or reset count to 0, limit = 80)
Result: Open spots = 80 (excludes the 50 surplus units now selling as regular stock).
PRECONDITION: Split Fulfillments must be enabled on the STOQ offer so multi-line orders can release this variant independently without prematurely releasing other items on backorder.
Surplus Rule

When a shipment leaves a surplus, recalculating ensures the preorder quota reflects only remaining in-transit POs, avoiding over-selling.

Scenario 03

Stock arrives & is fully absorbed (no surplus)

TRIGGER: Partial shipment arrives at Barrett and is fully absorbed by held preorders (units < committed orders).
1
BARRETT
Receives fewer physical units than the currently committed preorder volume.
2
TECHSERA
Pushes the received quantity delta to Shopify inventory via inventoryAdjustQuantities.
3
SHOPIFY
Available remains 0 because all incoming units are allocated to existing held orders.
4
SHOPIFY FLOW
Releases the fulfillment holds for exactly the number of orders covered by the arrived batch (filtered by heldByApp.id). Pending orders remain held.
5
STOQ (LIMIT RULE)
Do nothing — limit is untouched. Because 100% of the shipment is absorbed by waiting preorders (leaving 0 surplus), the remaining open spots accurately reflect unarrived PO units.
6
STOQ (DISPLAY)
Variant correctly stays in Preorder mode on the storefront because available inventory remains 0.
Partial Split Simulator Edit numbers
Committed
Units Arrived
10
Still Pending
Absorbed Rule: No Recalculation Needed

If a shipment gets fully absorbed by held preorders (nothing left over), do nothing — the math already holds whether shipments arrive all at once or in partial deliveries.

Scenario 04 — Resolved

PO registered on an in-stock item

STATUS: RESOLVED — Fully covered by the unified model (limit sits inert while stock > 0).
1
MOVEX
PO is created for a variant that currently has positive available inventory in Shopify.
2
TECHSERA
Writes PO quantity to backorder.incoming_po_quantity metafield via Shopify GraphQL (metafieldsSet).
3
SHOPIFY FLOW
Triggered via Workflow Trigger Extensions, calls STOQ API to update the variant limit.
4
STOQ (INERT)
Limit is updated in background. The storefront button stays "Add to Cart" while stock > 0 — zero customer UX impact.
5
STOQ (ACTIVATION)
When regular sales deplete stock to 0, STOQ auto-switches to Preorder mode with the limit already pre-staged and accurate!
Unified Model Handles Both Sequences

If stock sells out first: Transitions seamlessly into preorder with the staged limit ready.
If PO arrives first: Scenario 2's surplus formula (limit = count + in_transit − waiting) recalculates upon receipt, stripping arrived units and preventing inflation.

No Special Case Needed
The general formula automatically accommodates both orderings of events without custom conditional logic.
Comparison Matrix

Summary of the 4 Scenarios

The first two only ever affect the preorder limit. The next two only ever affect what happens to orders already on hold — never both at once.

SCENARIO 1 PO Arrives →

Preorder Limit Increment

Movex PO → Techsera writes backorder.incoming_po_quantity → Flow → STOQ Limit (+PO Qty).

Modifies: Preorder Limit Only
SCENARIO 2 Surplus Stock →

Hold Release & Surplus Recalc

Barrett receipt → Techsera delta → Flow releases heldByApp.id → STOQ recalculates limit (count + in_transit − waiting).

Modifies: Order Holds & Surplus Limit
SCENARIO 3 Partial Stock →

Partial Hold Release (Absorbed)

Committed drops by arrival count. Flow releases covered holds. Limit untouched because shipment is 100% absorbed (0 surplus).

Modifies: Order Holds (Limit Untouched)
SCENARIO 4 In-Stock PO →

Pre-staged In-Stock Limit (Resolved)

PO arrives while in-stock. Limit staged via unified formula, sits inert with zero UX impact until stock hits 0.

Modifies: Pre-staged Limit (Resolved)
Implementation Readiness

What's confirmed, what's open

Engineering validation status as of latest integration checks (STOQ & Architecture confirmations).

CONFIRMED

Shopify native available/committed math handles Flows 2 and 3

Nothing needs to be custom-built to track allocation — this is built-in Shopify inventory functionality.

CONFIRMED

Shopify Flow "Send HTTP request" can call STOQ API directly

Confirmed by STOQ support — custom headers (X-Auth-Token), external endpoints, and JSON payloads fully supported.

CONFIRMED

Metafield trigger & definition created in Shopify

Definition ID: gid://shopify/MetafieldDefinition/214024749169 (backorder.incoming_po_quantity, type number_integer). Techsera writes incoming PO quantities via metafieldsSet, and the installed Workflow Trigger Extensions app detects changes to trigger Shopify Flow.

CONFIRMED

reset_preorder_count is 100% safe with pending orders

Confirmed: STOQ's reset endpoint only clears the counter integer and never touches, modifies, or cancels active customer fulfillment holds.

CONFIRMED

Unified Surplus Recalculation Model

If a shipment is fully absorbed, limit is untouched. If it leaves a surplus, recalculate: limit = count + units_in_transit − preorders_waiting (or reset count to 0, limit = units_in_transit).

OPEN ITEM

In-transit PO visibility & surplus detection per shipment

Whether Techsera/Movex can expose, at any point in time, how many units remain in transit across outstanding POs and whether a given shipment left a surplus — depends on whether POs typically arrive as a single complete shipment or in partial deliveries (pending business/ERP-side confirmation).

OPEN ITEM

Fulfillment-hold release flow testing

Flow designed (filtering holds by heldByApp.id) — requires a clean rebuild and staging test before production go-live.

NOTE

Capacity consideration: Workflow Trigger Extensions Free Tier

The Free plan includes a ceiling of 5,000 trigger events / month. Not an immediate blocker for launch, but an operational metric to monitor as catalog updates and PO volume scale.

Slide Deck Overview