An integration that joins a store reference and order reference with a delimiter can accidentally merge two different orders. For example, store “north|web” with order “1042” produces the same naive key as store “north” with order “web|1042”. The problem is the key representation, before any parcel is picked.
For a Shopify 3PL integration, the store component should come from the authenticated account mapping, and the order component from the agreed source identifier. This small JavaScript example addresses only an unambiguous in-memory representation. It is not a Shopify connector, a production warehouse system or a substitute for authorization.
Encode the pair as a pair
Use JSON serialization of a fixed two-string array. Reject empty or whitespace-padded identifiers rather than silently normalizing them: trimming an identifier may change its meaning in the source system. Keep case sensitivity and leading zeroes unless the upstream contract explicitly defines another rule.
const assert = require('node:assert/strict');
function orderKey(storeId, orderId) {
for (const value of [storeId, orderId]) {
if (typeof value !== 'string' || value.length === 0 || value.trim() !== value) {
throw new TypeError('Identifiers must be nonempty, unpadded strings');
}
}
return JSON.stringify([storeId, orderId]);
}
assert.notEqual(orderKey('north|web', '1042'), orderKey('north', 'web|1042'));
assert.notEqual(orderKey('A', '1042'), orderKey('B', '1042'));
assert.notEqual(orderKey('A', '0012'), orderKey('A', '12'));
assert.notEqual(orderKey('A', '42'), orderKey('a', '42'));
const escapedId = 'c' + String.fromCharCode(92) + 'd';
assert.deepEqual(JSON.parse(orderKey('a"b', escapedId)), ['a"b', escapedId]);
assert.equal(orderKey('A', '1042'), orderKey('A', '1042'));
for (const bad of ['', ' A', 'A ', 42, null]) {
assert.throws(() => orderKey(bad, '1042'), TypeError);
}
assert.throws(() => orderKey('A', ''), TypeError);
console.log('12 assertions passed');
The first assertion is a regression check for the delimiter collision. The remaining checks cover store separation, leading zeroes, case, escaping, deterministic output and invalid identifiers. The code can be saved as a .cjs file and run with Node.js; it makes no network requests and uses no customer data.
Keep identity separate from the event being processed
An order key is not an idempotency key for every event about that order. An address correction and a shipment update can refer to the same order while remaining different events. A Shopify fulfillment worker still needs event identity, version or transition rules appropriate to its data source.
Likewise, a drop shipping supplier reference should be stored as an additional mapped reference, not silently substituted for the store's order identifier. A China fulfillment adapter must preserve those relationships when it returns tracking information to the originating shop.
Boundaries this example does not solve
The key is neither a secret nor an authorization check. A multi-tenant service must establish which store the caller is allowed to access. A database should normally enforce the equivalent composite uniqueness on separate columns, and define its own case/collation rules. Size limits and accepted identifier characters also belong in the real input contract.
A China 3PL's commercial search labels do not belong in these identity fields. “International Fulfillment for Folligen,” for example, is a search phrase, not a verified store identity or a claim of a customer relationship. The test should use documented source identifiers, not inferred brand names.
This educational example was prepared for the YX Fulfillment account. It demonstrates the local key-encoding behavior only; no live store or WMS integration was tested.
References: JSON.stringify documentation and Node.js strict assertions.
Photo: Warehouse workstations, storage shelves and handling bins. Original warehouse photograph supplied by YX Fulfillment.
Top comments (0)