Developer guide
Architecture, stored data, the REST endpoint, templates, shipment providers and the public functions of Free and Pro.
Architecture
- Free (
siteryn-track-order, namespaceSiteryn_Track_Order) boots onplugins_loadedonce WooCommerce and its requirements are met, then firessiteryn_track_order_loaded. Its public extension API is version1.0(Plugin::API_VERSION). - Pro (
siteryn-track-order-pro, namespaceSiteryn_Track_Order_Pro) starts onsiteryn_track_order_loadedand firessiteryn_track_order_pro_loaded. Licensed features start oninitand firesiteryn_track_order_pro_features_loaded. Pro only uses Free's documented hooks and interfaces. - Orders are read and written only through the WooCommerce order CRUD, so HPOS and legacy storage both work. No custom tables.
- Every customer-facing view goes through
Orders\Lookup(or the owner check for signed-in links). Filters that receive tracking data only run for orders the visitor was verified for.
Data stored
| Where | Key | Removed on uninstall |
|---|---|---|
| Option | siteryn_track_order_settings, siteryn_track_order_version, siteryn_track_order_page_id | Yes (the page stays) |
| Options (AI) | siteryn_track_order_ai_settings, _ai_credentials (encrypted, not autoloaded), _ai_usage, _ai_connections and related | Yes |
| Transients | siteryn_track_order_rl_* (15-minute lookup counters), siteryn_track_order_outdated_templates, AI caches | Yes |
| Order meta | _siteryn_track_order_shipment (Free shipment), _siteryn_track_order_locale, _siteryn_track_order_language | Only with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA |
| Pro options | siteryn_track_order_pro_settings, _secrets (Ship24 key, Twilio token, webhook secret), _version, _active_orders, _sync_cursor, _stats, _webhook_seen, _webhook_out_status, license data | Yes (with Pro) |
| Pro order meta | _siteryn_track_order_pro_shipments, _siteryn_track_order_pro_sms_optin | Only with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA |
| Pro user meta | siteryn_track_order_pro_notify (notification preferences) | Only with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA |
Pro shipment array
| Key | Meaning |
|---|---|
id | Stable id (sh_…, or primary for a converted Free shipment) |
carrier, carrier_name, tracking_number, tracking_url, shipped_at | As in Free |
items | Order item id => quantity in this shipment (empty: the whole order) |
status | pending, in_transit, out_for_delivery, delivered, exception, returned or empty |
status_detail, eta, delivered_at | Carrier detail text, estimated delivery and delivery time (Unix timestamps) |
events | Newest first, at most 50: time, status, description, location |
source, synced_at, sync_fails, notified, alerted | Bookkeeping |
REST endpoint
POST /wp-json/siteryn-track-order/v1/track, used by the tracking form.
| Parameter | Notes |
|---|---|
order_number | Required |
email | Billing email; optional for the order's signed-in owner |
nonce | Required by default: wp_create_nonce( 'siteryn_track_order_lookup' ) |
extra | Extra verification fields (for example Pro's postcode) |
lang | WPML/Polylang language code; the result renders in it |
Success returns { "data": <tracking data>, "html": "<result card>" } with Cache-Control: private, no-store. Errors: disabled (403), login_required (401), rate_limited (429), invalid_number / invalid_email (400), not_found (404), invalid_nonce (403). The same verification and throttling as the form apply.
Pro adds POST /wp-json/siteryn-track-order-pro/v1/shipments, the signed incoming webhook.
Tracking data
Every view renders one array (filter siteryn_track_order_tracking_data):
| Key | Contents |
|---|---|
order_id, order_number, date_created | Order id, number and Unix time |
status, status_label | WooCommerce status slug and name |
stage, message, notice_type | Stage, status message and success / info / warning / error |
timeline | steps (key, label, state complete/current/upcoming, date) and halted |
shipments | id, source, carrier, tracking_number, tracking_url, shipped_at; Pro adds status, status_label, status_detail, eta, delivered_at, items, events, carrier_id, carrier_color, carrier_logo |
summary | items, item_count, total, shipping_method, ship_to (per settings) |
pro | Pro only: next_eta, unshipped_items |
Templates
Every template declares a @version and can be overridden by copying it to yourtheme/siteryn-track-order/ with the same relative path. Outdated overrides are flagged in an admin notice and in System Status.
| Plugin | Templates | Override folder |
|---|---|---|
| Free | track-order.php, form.php, result.php, recent-orders.php, account-tracking.php, parts/notice.php, parts/timeline.php, parts/shipments.php, parts/summary.php | yourtheme/siteryn-track-order/ |
| Pro | parts/shipments.php, parts/brand-header.php, parts/brand-footer.php, parts/recommendations.php, parts/ai-assistant.php | yourtheme/siteryn-track-order-pro/ |
| Pro emails | emails/siteryn-shipment-update.php, emails/plain/siteryn-shipment-update.php | yourtheme/woocommerce/ |
Add-ons can register their own template folder with Templates::register_root( $prefix, $dir, $theme_subdir, $overridable ); their templates are then named "prefix:path.php" (Pro uses pro:).
Result sections
The result card is built from sections you can add, remove or reorder:
add_filter( 'siteryn_track_order_result_sections', function ( $sections, $data, $order ) {
$sections['returns'] = function ( $data, $order ) {
return '<p class="my-returns">Need to return something? <a href="/returns/">Start a return</a></p>';
};
return $sections;
}, 10, 3 );
A value is a template name or a callable returning HTML (passed through wp_kses_post()). My Account shows only notice, timeline and shipments.
Shipment providers and tracking links
Tracking numbers come from shipment providers (Orders\ShipmentProviderInterface: get_id(), get_shipments( WC_Order $order ) returning Orders\Shipment objects). Free registers order_meta; Pro replaces it with pro. Links come from resolvers (Orders\TrackingUrlResolverInterface::resolve()); a URL stored on the shipment always wins.
add_filter( 'siteryn_track_order_carriers', function ( $carriers ) {
$carriers['pathao'] = array(
'label' => 'Pathao',
'url' => 'https://merchant.pathao.com/tracking?consignment_id={tracking_number}',
);
return $carriers;
} );
Custom order numbers
When another plugin changes order numbers, map the typed number to an order id. The resolved order's get_order_number() must equal the typed number, or it is rejected.
add_filter( 'siteryn_track_order_resolve_order_id', function ( $order_id, $number ) {
$found = wc_get_orders( array( 'limit' => 1, 'return' => 'ids', 'meta_key' => '_order_number', 'meta_value' => $number ) );
return $found ? (int) $found[0] : $order_id;
}, 10, 2 );
Extra verification fields
Print fields on siteryn_track_order_form_fields named siteryn_track_order_extra[key] with data-siteryn-track-extra="key", then check them in siteryn_track_order_verify_guest. Pro's postcode check works this way.
Functions
| Function | Returns |
|---|---|
siteryn_track_order_lookup( $order_number, $email = '', $user_id = null, $extra = array() ) | WC_Order|WP_Error with the same verification and throttling as the form |
siteryn_track_order_get_tracking_data( $order ) | Tracking data. Does not check access. |
siteryn_track_order_get_shipments( WC_Order $order ) | Shipment[] |
siteryn_track_order_save_shipment( WC_Order $order, array $data ) | Stores or removes the Free order-screen shipment |
siteryn_track_order_carriers() | Carrier list |
siteryn_track_order_page_url( $order = null ) | Tracking page URL (with the order's deep link) |
siteryn_track_order_render() | Shortcode output |
siteryn_track_order_pro_get_shipments( $order ) | Pro shipments keyed by id |
siteryn_track_order_pro_save_shipment( $order_id, array $data ) | Adds or updates (by id or tracking number); detects the carrier when empty |
siteryn_track_order_pro_delete_shipment( $order_id, $shipment_id ) | Removes a shipment |
siteryn_track_order_pro_detect_carrier( $tracking_number ) | Carrier id or empty |
siteryn_track_order_pro_sync_order( $order_id ) | Fetches live tracking now (licensed, integration set up) |
Check function_exists() first; the functions exist once the requirements are met.
Pro integration interfaces
Carriers\CarrierApiInterface(get_id,get_label,is_configured,supports,fetchreturning aCarriers\TrackingResultorWP_Error), registered withsiteryn_track_order_pro_carrier_apis. Ship24 is built in.Notifications\SmsGatewayInterface(get_id,get_label,is_configured,send( $e164_to, $message )), registered withsiteryn_track_order_pro_sms_gateways. Twilio is built in.- Background jobs:
siteryn_track_order_pro_sync,_sync_order,_send_sms,_webhook_out,_dailyand_license_check(Action Scheduler, else WP-Cron).
JavaScript
The storefront script handles the lookup over REST, focus and copy buttons, and fires no public events. Without JavaScript the form posts normally. The CSS and JavaScript load only on the tracking page and on pages with the shortcode or block.
Multilingual
wpml-config.xml registers the customer-facing settings for WPML and Polylang. Siteryn_Track_Order\Multilingual is a public helper (current and default language, translate_id(), switch_to_order() and more) that does nothing without a multilingual plugin. The tracking page resolves to its translation, and Pro sends emails and texts in the order's language.