Collecting an order: ready, arrival and handover¶
What happens to an order the customer collects, from the moment it's placed to the moment it's
handed over (or cancelled because nobody came). It applies to every collection order: the single
"collect from us" option every plan has (collect-default, see
Locations) and collection from any store
(Click and Collect).
One service, PickupService (commerce-core/.../order/collection/), moves a collection order on.
The admin order page, the fulfilment portal, the Badger POS
app, the customer's arrival page and the hold-expiry job all go through it, so the order, the
customer's emails and the store's task lists can't disagree.
The lifecycle¶
| Stage | Set by | What the customer gets |
|---|---|---|
| To prepare | Placing the order | The order confirmation page and email say where to collect from and show their collection code; the page adds "We'll email you when it's ready to collect, usually by 13:12 today" (from the ready-by time, in the shop's time zone) |
| Ready | Admin Ready for collection, portal Mark ready to collect, POS Ready | The "ready to collect" email (once), with the code and a link to the arrival page |
| On the way / here | The customer, on the arrival page | Nothing; the store is told |
| Being brought out | A member of staff on a till ("I've got this one") | Their arrival page says someone from the shop is on their way out, with the staff member's message |
| Collected | Admin Collected, portal Customer has collected, POS handover | A short thank-you note (orderCollected). No dispatch email |
| Cancelled | The hold running out, or a manual cancellation | The usual cancellation email, if the site sends them |
The order page follows the stage: once the order is ready it says "It's ready to collect", once collected "Collected. Thank you.", and once cancelled that it wasn't collected in time. The collection code is shown only while the order is to prepare or ready.
Ready and collected ride on the pack and dispatch pipelines, so stock, payment capture, fulfilment states and the order list behave as they do for an order that is sent.
Where an order has got to is stored on the order as collection (Order.getCollectionDetails()):
its stage, location code, collection code, when it should be ready by, when it was made ready, how
long it is held (holdUntil), when it was collected, what has been picked per line, the customer's
arrival notice and when the reminder went. A submit-pipeline step (startCollectionProcessor) sets
it up as the order is placed, before the confirmation email; an order placed before this existed
gets it the first time anything touches it.
Ready by is the time of placing plus the preparation time checkout promised
(DeliveryOptionBean.collectionPrepMinutes), else the location's preparation time
(collectionSettings.prepMinutes). An order collected on a later day or in a slot (see Collection and
delivery slots) is ready by, and ready from
(collection.readyFrom), that day's opening time or the slot's start: if staff mark it ready
sooner, the "ready to collect" email waits until then (readyEmailDueAt, sent by the hold job) and
the hold runs from then. On an order that is partly collected and partly delivered, the slot is the
collected items' own (Order.collectionSlot, read through collectionSlotOrNull()), so the ready
email, the hold, the arrival page, the portal and the POS task follow it exactly as on a whole
collection. Held until is the moment it was made ready plus the
location's hold days (collectionSettings.holdDays, default 7).
Collection codes¶
Each collection order gets a random six-character code made of letters and digits nobody confuses
(no 0/O/Q, 1/I/L, 2/Z, 5/S or 8/B). It's printed in the confirmation,
ready and reminder emails ("Show this code when you collect"). At handover, staff either check the
code (typed codes are compared ignoring case, spaces and hyphens) or check the name on the order.
The code is shown to staff in the POS app; it is never logged.
The arrival page¶
The ready email links to /collect/{token}: a page with no sign-in where the customer sees where to
collect (address, phone, opening hours with today marked, directions, the store's collection
instructions) and can say:
- I'm on my way, choosing when they'll arrive (5 to 60 minutes);
- I'm here. At a location with the
KERBSIDEcapability they also give their bay or space and their car, and are asked to stay in it; elsewhere it just tells the store they're at the counter. Once they've said they're here, On your way? is no longer offered.
While the order is being prepared or is ready, the page also shows the collection code to give at the counter.
It only works while the order is ready and not yet collected or cancelled; otherwise it says where
the order has got to. The page shows the order number, the collection code and the store, never the
customer's name or items (the link is the customer's alone, like the email that carries it), is noindex, Cache-Control: private, no-store and Referrer-Policy: no-referrer. Text
comes from collect.arrival.* message keys (template templates/nova/collect/arrival.html).
The link. The token is base64url(orderId|expiry).base64url(HMAC-SHA256), signed with a random
secret per site (collection-link-signing-key, created on first use and never shown;
CollectionLinkTokenService). It names the order and nothing else, can't be used on another shop,
and expires a day after the hold ends. Links are minted on whichever node marks the order ready and
checked on the storefront, which is why the key lives in site config rather than an environment
variable.
What happens. The notice is written to the order with a guarded, targeted update (only while
it's ready), recorded in its activity, and broadcast as a CollectionArrivalEvent on the
fulfilment-events-exchange fanout. The event carries ids, the state, the ETA and the bay, never
the name or vehicle. The notice's fields are written one by one, so saying "I'm here" after "on my
way" keeps a member of staff's claim (below).
Bringing the order out (the claim)¶
When a customer has said they're coming or here, one member of staff says on their till "I've got
this one" (POST /v1/pos/{locationId}/tasks/{orderId}/arrival/claim, see Mobile
POS), so two people don't both walk out to the car park, or
nobody does.
- One person. The claim is one guarded
findAndModifyon the order (collection.arrival.claimedByUserId,claimedAt,claimMessage): it only takes while the collection is ready, the order isn't closed, the customer has said they're coming or here, and nobody else holds it. A colleague who tries afterwards is refused (409, "A colleague is already bringing this order out"); the task shows who. The same person claiming again keeps the claim and when it was made and replaces the message, so a retried request is harmless. They can let it go (DELETEon the same path) if they're called away; only they can. - The other tills see the claim in the task and the arrivals list (
arrival.claimedBy,claimedByMe). A claim is broadcast as its own event (CollectionArrivalClaimEvent, typecollection-arrival-claim, ids only) on the fulfilment events exchange, so no node mistakes it for a new arrival. It is not pushed to the tills: a notification would sound on every phone for something nobody needs to act on, and a silent "refresh yourself" push isn't delivered reliably enough to be what stops a second person (the refusal is). The app shows colleagues' claims on its next look at the arrivals list. The fulfilment portal receives it as acollection-arrival-claimstream event (the order number andCLAIMEDorRELEASED), which never raises its "customer here" banner. - The customer isn't emailed or texted (they're sitting in a car park). Their arrival page
checks every 15 seconds, while it's open and visible and they've said they're coming, with
GET /collect/{token}/status, a small JSON answer from the same storefront controller as the page's own forms:{state, arrivalState, staffComing, staffMessage}. Once someone has the order, the page says Someone from the shop is on their way out to you with your order. and shows the message as plain text. The answer never says who: the signed link is the only key, and it may have been forwarded. When the order is collected or cancelled the page reloads and stops checking. Unknown links get404with{state: "INVALID"}; answers areCache-Control: private, no-store,Referrer-Policy: no-referrerandX-Robots-Tag: noindex. - The claim and its release are recorded in the order's activity (
COLLECTION_ARRIVAL_CLAIMED,COLLECTION_ARRIVAL_RELEASED). The message is the member of staff's own words: never logged.
The fulfilment portal¶
The portal's board has a Customers collecting panel listing, for the user's fulfilment partners (or the whole site for an administrator), orders whose customer said in the last three hours that they're on their way (with the time) or here (with bay and vehicle). An arrival event raises the portal's alert banner ("Customer here for #1042") and refreshes the panel in place, over the same server-sent events stream as new orders.
On the board, an order's Mark ready to collect and Customer has collected record the collection stage too, as do the admin's per-partner buttons.
POS tasks¶
The Badger POS app shows a store's collection orders as tasks, through /v1/pos/{locationId}/...
(the store's code or Stripe Terminal location id; the agent must be allowed to work there). See
Mobile POS and the API reference. The same
task list can include web orders the store sends (ship tasks).
On a split order (some items collected, the rest delivered) the task lists only the items to
collect; each line says handover: COLLECT, and deliveredItemCount and deliveredLines say what
is being delivered instead. The app shows 1 more item is being delivered under the items, so
staff don't look for them.
Items that can't be found. A picker who can't find an item (or finds it damaged) marks it short rather than marking the whole order ready with items missing. The short units are cancelled and the customer isn't charged for them: refunded if the payment was taken, captured that much less if it was only authorised (the usual case for a collection, paid at handover), or handed back in cash at the counter for an order paid in cash. The customer gets one email listing everything that couldn't be picked when the order is made ready, alongside the ready email, and what is still coming, whether it is made ready on the till, in the admin or in the fulfilment portal. Where the shop allows it, staff can pick a substitute taxed the same way, at no more than the ordered price. If nothing would be left, the order is cancelled. See Items that can't be picked. Each line also says where the store keeps it (aisle, bay, shelf) when it has been placed, and the pick list is in walk order.
The admin order page¶
On a split order the admin order page has a Collection panel and a Delivery panel. The Collection panel shows, while the collection is still open:
- the customer's latest notice from the arrival page: The customer is here (with bay and vehicle), or The customer is on the way (with the time they expect to arrive), and when they told us. It goes once the items are collected or the collection is cancelled;
- how many of the collected items have been picked (2 of 2 picked, with a progress bar). Only the collected items count: the delivered ones are never picked at the store;
- how many items are being delivered instead (1 more item is being delivered, not collected here), with the delivery's state (Awaiting fulfilment, Packing, Partly dispatched, Dispatched), which links to the Delivery panel. The Delivery panel shows the same state in its header.
Push notifications¶
Every device registered at a store with an Expo push token (PUT /v1/pos/{locationId}/devices/{id})
is sent:
data.type |
When | Says |
|---|---|---|
new-store-task |
A collection order is placed for the store (taskType: COLLECTION) |
"New order to prepare: order #1001 is to be collected from Leeds" |
new-store-task |
A web order is placed with items the store sends (taskType: SHIP) |
"New order to send: order #1002 is to be sent from Leeds" |
customer-on-the-way |
The customer says they're coming | "Order #1001: arriving in about 15 min" |
customer-arrived |
The customer says they're here | "Order #1001: bay 3" |
Each message is {to, title, body, sound: "default", channelId: "default", priority: "high", data:
{type, taskType, orderId, orderNumber, locationCode, url: "badgerpos://tasks/<orderId>", siteId}}. Every
push from the platform carries data.siteId, the shop it is about, so the app can open its link in
that shop. Messages carry
the order number and bay at most, never the customer's name or vehicle: they pass through Expo,
Apple and Google and show on a lock screen.
The worker's PosPushListener reads the events from its own durable queue on the fulfilment
events exchange (pos-push-events, shared by every worker, so each event is pushed once) and
PosPushService sends them to https://exp.host/--/api/v2/push/send in batches of 100. Tokens
Expo reports as DeviceNotRegistered are removed from their device. Only ids and counts are
logged.
Push is off unless the global setting POS Push Notifications (pos-push-enabled) is on, so
development and test stacks never call Expo. If the Expo project requires an access token, set
Expo Access Token (pos-expo-access-token, a secret) or the EXPO_ACCESS_TOKEN environment
variable on the worker.
Emails¶
| Template | When | Notes |
|---|---|---|
orderPlaced |
Placed | Shows the collection code |
orderReadyForCollection |
Ready, once | Code and the arrival link |
orderCollectionReminder |
A day before the hold ends, once | Code, arrival link, until when it's kept. Not sent for a hold of a day or less |
orderCollected |
Handed over, once | Thank-you note; no dispatch email is sent |
All are queued to the worker like the other order emails; see Transactional email.
Split orders (some items collected from the store, the rest delivered) use the same templates:
| Template | Split order |
|---|---|
orderPlaced |
Two sections: Collect from <store> (address, instructions, slot or ready-from day, code, the collected items) and Delivered to (address, delivery option, the delivered items). Totals show Collection: Free and the delivery charge |
orderReadyForCollection, orderCollectionReminder, orderCollected |
The collected items only, the store from the collection option, and "The rest of your order is being delivered separately" (or "is on its way" / "has been delivered", once the delivered items have gone) |
orderDispatched, orderPartialDispatched |
The delivered items only, and a note that the collected items aren't part of this delivery |
An email sent about one part lists only that part's lines (partLineIds in the job's model). The
order page (orderSummaryExtension, in Nova and Brock) has the same two parts: the
items listed under Collect from <store> and Delivery headings, the collection panel
with the store, its slot and the code (shown only while the collection is open), the tracking for
the delivered part, and a free Collection row in the totals.
When nobody comes¶
The worker's CollectionHoldJob runs every 15 minutes (badger.collection.hold-schedule) and, for
each site:
- Reminds customers whose ready order's hold ends within a day (
orderCollectionReminder). - Cancels ready orders whose hold has ended, through
OrderCancellationService: the payment is refunded or released, the stock goes back where it was taken (the collection store), the order records the reason ("Not collected: kept for collection at leeds until ..."), and the customer gets the site's cancellation email if it sends them.
Several workers can run it at once: each reminder and cancellation is first claimed on the stored
order with a guarded findAndModify. A cancellation that fails (a refund refused, say) is logged
and tried again an hour later.
Split orders. On an order where some items are collected and the rest delivered, only the
collection is cancelled, with OrderCancellationService.cancelPart(..., COLLECTION, ...) and
the same reason text ("Not collected: kept for collection at leeds until ..."): the uncollected
items are refunded and go back into the store's stock, the collection is marked cancelled, and the
customer gets the orderPartCancelled email saying the rest of their order isn't affected. The
delivery carries on, or, if it has already gone, the order becomes DISPATCHED. (Cancelling the
whole order would be refused once the delivery had been dispatched, and retried every hour for
ever.) If the delivery was cancelled too, nothing else is left, so the whole order is cancelled as
above. While the payment is only authorised (a site that captures at dispatch, with nothing sent
yet) the part can't be refunded, so the cancellation is refused and retried each hour; it goes
through once the delivery is dispatched and the payment captured, or as a whole-order cancel if the
delivery is cancelled. See Cancelling one part of a split order.
Code¶
| Piece | Where |
|---|---|
PickupService, PickupServiceImpl, CollectionLinkTokenService, CollectionException |
commerce-core/.../order/collection/ |
CollectionDetails, CollectionArrival, CollectionOrderRepository |
common/.../order/ |
Placing: StartCollectionProcessor, AnnounceCollectionTaskProcessor |
commerce-core/.../pipeline/impl/ |
Events: CollectionArrivalEvent, CollectionArrivalClaimEvent, CollectionTaskEvent, FulfilmentEventPublisher |
commerce-core/.../fulfilment/events/ |
| Arrival page and its status poll | web-mvc/.../render/CollectArrivalController.java, templates/nova/collect/arrival.html |
| Portal | FulfilmentEventListener, FulfilmentEventHub.deliverArrival / deliverArrivalClaim, FulfilmentWorkService.arrivals |
| POS tasks | PosTaskService, PosTaskView (commerce-core/.../pos/), PosController |
| Push and hold job | worker/.../pos/push/ (PosPushListener, PosPushService, ExpoPushClient), worker/.../order/collection/CollectionHoldJob.java |
Known limits¶
- Orders placed before this release have no collection details until something touches them, so they don't appear in a store's POS task lists.
- Picks, un-picks (taking back a wrong scan) and arrival notices are targeted writes, but readying and handing over save the whole order; a pick scanned at the very moment another till marks the order ready can be lost. A claim on an arrival can't be lost this way: readying saves the whole order only before the customer has the arrival link (the move to ready, or the held ready email being queued), so there is no arrival or claim yet, and handing over ends the collection, after which a claim no longer matters.