Bare Necessities
Preorder & Backorder Sync / Architecture & Scenarios
Executive Shareout & 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
2
Barrett
Warehouse / Physical
3
Techsera
Integration / Bridge
4
Shopify
Storefront & Holds
5
STOQ
Preorder Limits
Scenario 01 — Metafield 1 & Flow 1

New PO arrives in Movex

TRIGGER: PO registered in ERP — zero physical units have arrived yet.
1
MOVEX
PO is created — quantity, PO number, and expected ship date are recorded. No physical stock exists yet.
2
TECHSERA
Writes the incoming PO's quantity and PO number to the variant's backorder.incoming_po_quantity metafield (JSON) via metafieldsSet. Including the PO number guarantees each write is unique — even if two POs carry the same quantity back-to-back, the trigger won't miss one by comparing identical values.
Shopify — metafieldsSet Mutation
View JSON GraphQL 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 (Type: json with PO uniqueness):
{
  "metafields": [
    {
      "ownerId": "gid://shopify/ProductVariant/{{variant_id}}",
      "namespace": "backorder",
      "key": "incoming_po_quantity",
      "value": "{\"po_number\":\"PO-4521\",\"quantity\":100}",
      "type": "json"
    }
  ]
}
3
SHOPIFY FLOW (FLOW 1)
Triggered when backorder.incoming_po_quantity changes (via Workflow Trigger Extensions app). Extracts quantity from the JSON payload and initiates the read → calculate → write sequence.
4
STOQ
Current preorder_max_count is read for that variant — STOQ's update endpoint sets an absolute value, so the current limit is queried first.
STOQ — Read Variant Limit API
5
STOQ
New absolute limit is written: current limit + quantity.
STOQ — Update Variant Settings PATCH
Interactive Math Simulator Edit numbers
Current Limit
New PO Qty
180
New STOQ Limit
Why JSON? Snapshot Uniqueness

The trigger compares against a stored snapshot and only fires when the value differs from the last recorded one — a plain repeated number would risk being silently dropped, which is why po_number is included (confirmed with Workflow Trigger Extensions support).

⚠️ Baseline snapshot note: The trigger needs an existing snapshot to compare against. The very first write after enabling the trigger can be absorbed into that baseline instead of firing — a one-time initial setup consideration for testing.

Scenario 02 — Metafield 2 & Flow 2

Stock arrives, covers preorders & leaves surplus

TRIGGER: Physical stock arrives at Barrett and exceeds held preorders (leaves real surplus inventory).
1
BARRETT
Receives physical shipment into warehouse storage.
2
TECHSERA
1) Pushes received inventory delta to Shopify via inventoryAdjustQuantities.
2) Writes the received shipment's identifier (shipment_id) and the PO it is being received against (po_number), along with the updated remaining in-transit total across all open POs, to Metafield 2: backorder.units_in_transit (JSON) via metafieldsSet.
Critical Rule: units_in_transit is an Aggregate Total

⚠️ units_in_transit is always the running total across every open PO for this variant — not the specific shipment that just arrived. When a shipment fully closes out one PO, the new value written is the sum of whatever other POs are still outstanding, not zero (unless this was genuinely the last open PO).

Shopify — inventoryAdjustQuantities Mutation Metafield 2 Def ID: TBD (Pending Creation)
View JSON GraphQL Payload (units_in_transit)
# Definition ID: TBD (Pending creation in Shopify — ProductVariant)
{
  "metafields": [
    {
      "ownerId": "gid://shopify/ProductVariant/{{variant_id}}",
      "namespace": "backorder",
      "key": "units_in_transit",
      "value": "{\"shipment_id\":\"SHIP-8842\",\"po_number\":\"PO-4521\",\"units_in_transit\":80}",
      "type": "json"
    }
  ]
}
3
SHOPIFY
Available turns positive natively. Committed does NOT drop automatically — orders stay on hold until explicitly released.
4
SHOPIFY FLOW (HOLDS)
Triggered by inventory change (prior <= 0 and current > 0). Filters specifically by heldByApp.id (STOQ holds only) and releases them.
Shopify — fulfillmentOrderReleaseHold Mutation
5
SHOPIFY FLOW (FLOW 2 — RECALCULATE)
Triggered by backorder.units_in_transit JSON update:
• Extracts units_in_transit from payload and reads native committed.
• Reads preorder_count from STOQ.
• Calculates: new_limit = preorder_count + units_in_transit − committed.
• Writes new_limit to STOQ via PATCH (equivalent to count 0, limit = units_in_transit − committed).
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)
Remaining Committed: 0 waiting
Units in Transit: 80 (PO#2)
Formula: 50 (count) + 80 (transit) − 0 (committed) = 130
Open Preorder Spots: 130 − 50 = 80 (excludes 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.
Metafield 2 & Snapshot Uniqueness

Includes shipment_id in the JSON value to guarantee each write is unique, preventing the trigger from silently dropping consecutive identical units-in-transit totals.

⚠️ Baseline snapshot note: Like Flow 1, the very first write after enabling the trigger establishes the comparison baseline snapshot.

Scenario 03 — Metafield 2 & Flow 2

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
1) Pushes received quantity delta to Shopify via inventoryAdjustQuantities.
2) Writes received shipment identifier, the PO it is being received against, and updated remaining in-transit units to Metafield 2: backorder.units_in_transit (JSON with shipment_id and po_number).
Shopify — metafieldsSet Mutation Metafield 2 Def ID: TBD (Pending Creation)
View JSON GraphQL Payload (units_in_transit)
# Definition ID: TBD (Pending creation in Shopify — ProductVariant)
{
  "metafields": [
    {
      "ownerId": "gid://shopify/ProductVariant/{{variant_id}}",
      "namespace": "backorder",
      "key": "units_in_transit",
      "value": "{\"shipment_id\":\"SHIP-8842\",\"po_number\":\"PO-4521\",\"units_in_transit\":40}",
      "type": "json"
    }
  ]
}
3
SHOPIFY
Available remains 0 because all incoming units are allocated to existing held orders.
4
SHOPIFY FLOW (HOLDS)
Releases fulfillment holds for exactly the number of orders covered by the arrived batch (filtered by heldByApp.id). Pending orders remain held.
5
SHOPIFY FLOW (FLOW 2 — RECALCULATE)
Extracts units_in_transit from JSON and runs the universal formula: new_limit = preorder_count + units_in_transit − committed.
Because all arrived units were absorbed by waiting preorders, remaining open spots accurately reflect unarrived PO units without overselling.
6
STOQ (DISPLAY)
Variant correctly stays in Preorder mode on storefront because available inventory remains 0.
Partial Split Simulator Edit numbers
Committed
Units Arrived
10
Still Pending
Universal Formula Consistency

Flow 2 executes the exact same mathematical formula (preorder_count + units_in_transit − committed) across all physical stock receipt scenarios.

*Uses JSON with shipment_id to guarantee trigger change-detection on every partial shipment.

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 and PO number to backorder.incoming_po_quantity metafield (JSON) via Shopify GraphQL (metafieldsSet).
3
SHOPIFY FLOW (FLOW 1)
Triggered via Workflow Trigger Extensions, calls STOQ API to update the variant limit in the background.
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: Flow 2's formula (triggered via JSON units_in_transit) 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

Two distinct JSON metafields drive two dedicated Flows: one for incremental PO creation, and one for physical shipment recalculations.

SCENARIO 1 PO Arrives →

Metafield 1: incoming_po_quantity (JSON)

Movex PO → Techsera writes {po_number, quantity}Flow 1 reads current limit and writes limit + quantity.

Flow 1: Incremental Limit Add
SCENARIO 2 Surplus Stock →

Metafield 2: units_in_transit (JSON)

Barrett arrival → Techsera writes {shipment_id, units_in_transit}Flow 2 recalculates: count + units_in_transit − committed.

Flow 2: Surplus Recalculation
SCENARIO 3 Partial Stock →

Metafield 2: units_in_transit (JSON)

Partial arrival → Techsera writes {shipment_id, units_in_transit}Flow 2 runs universal formula; all units absorbed with 0 surplus.

Flow 2: Absorbed Recalculation
SCENARIO 4 In-Stock PO →

Metafield 1: incoming_po_quantity (JSON)

PO on in-stock item → Flow 1 stages limit in STOQ in background (sits inert until stock reaches 0).

Flow 1: Pre-staged Limit (Resolved)
Interactive Sandbox

Live Preorder Event Simulator

Simulate real-world PO creations, customer preorders, and inventory arrivals to watch the 5 core system variables and Flows react in real time.

Storefront: PREORDER MODE (CTA: Preorder)
STOQ Limit
0
STOQ preorder_max_count (via API)
Shopify Available
0
Shopify native
STOQ Preorders
0
STOQ preorder_count (via API)
Shopify Committed
0
Shopify native
Units in Transit
0
backorder.units_in_transit (Shopify metafield)
⚠️ units_in_transit is always the running total across every open PO for this variant — not the specific shipment that just arrived. When a shipment fully closes out one PO, Techsera writes the sum of whatever other POs are still outstanding (not zero, unless this was genuinely the final PO).
Demo Scenarios:
# Event Storefront CTA Limit Available Count Committed In Transit System Reaction & Formula Calculation
Editing Mode Active

Slide Deck Overview