Developers
Save the UPCS Code with an Order
Persist a customer's UPCS code, coordinates and share link with an order in your own database, with server-side verification and a schema example.
Updated 14 October 2026 · 2 min read
When a customer picks a location during checkout, the useful outcome is a code and coordinates attached to the order, where your warehouse and couriers can see them. In custom code you do this yourself.
Schema
CREATE TABLE order_locations (
order_id BIGINT UNSIGNED PRIMARY KEY,
upcs_code VARCHAR(16) NOT NULL,
latitude DECIMAL(9,6) NOT NULL,
longitude DECIMAL(9,6) NOT NULL,
share_url VARCHAR(255) NULL,
verified_at DATETIME NULL
);
A separate table keeps the orders table clean and makes it easy to delete location data on its own schedule; see location data and GDPR concepts. Adding columns to the orders table is also fine; see storing a UPCS code in your database.
Flow on submit
$code = strtoupper(trim($request->input('upcs_code', '')));
if ($code !== '') {
$location = lookupUpcs($code); // server-side call, see lookup guide
if ($location === null) {
return back()->withErrors(['upcs_code' => 'We could not verify that code.']);
}
DB::transaction(function () use ($order, $code, $location) {
OrderLocation::updateOrCreate(
['order_id' => $order->id],
[
'upcs_code' => $code,
'latitude' => $location['location']['latitude'],
'longitude' => $location['location']['longitude'],
'share_url' => $location['share_url'],
'verified_at'=> now(),
]
);
});
}
lookupUpcs wraps the lookup endpoint. Saving values from the lookup, not from the form, means a user cannot post coordinates that disagree with the code.
Make it safe to repeat
Customers double-click and payment webhooks retry. Using updateOrCreate keyed on order_id makes the write idempotent; see idempotency for location API calls.
Show it where it is needed
Display the code and share link on the order screen, packing slip and dispatch notes. Keep the postal address alongside; the code complements it and does not replace it.
Frequently asked questions
Do the store plugins already save this?
Yes. The WordPress/WooCommerce plugin saves the code, latitude and longitude as order meta, and the PrestaShop and OpenCart modules attach the location to the order. This page is for custom code.
What if the customer skips the map?
Store nulls and fall back to the postal address. The code is optional by design.
