Developer guide

Architecture, stored data, the REST endpoint, templates, shipment providers and the public functions of Free and Pro.

FreePro

Architecture

Data stored

WhereKeyRemoved on uninstall
Optionsiteryn_track_order_settings, siteryn_track_order_version, siteryn_track_order_page_idYes (the page stays)
Options (AI)siteryn_track_order_ai_settings, _ai_credentials (encrypted, not autoloaded), _ai_usage, _ai_connections and relatedYes
Transientssiteryn_track_order_rl_* (15-minute lookup counters), siteryn_track_order_outdated_templates, AI cachesYes
Order meta_siteryn_track_order_shipment (Free shipment), _siteryn_track_order_locale, _siteryn_track_order_languageOnly with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA
Pro optionssiteryn_track_order_pro_settings, _secrets (Ship24 key, Twilio token, webhook secret), _version, _active_orders, _sync_cursor, _stats, _webhook_seen, _webhook_out_status, license dataYes (with Pro)
Pro order meta_siteryn_track_order_pro_shipments, _siteryn_track_order_pro_sms_optinOnly with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA
Pro user metasiteryn_track_order_pro_notify (notification preferences)Only with SITERYN_TRACK_ORDER_REMOVE_ALL_DATA

Pro shipment array

KeyMeaning
idStable id (sh_…, or primary for a converted Free shipment)
carrier, carrier_name, tracking_number, tracking_url, shipped_atAs in Free
itemsOrder item id => quantity in this shipment (empty: the whole order)
statuspending, in_transit, out_for_delivery, delivered, exception, returned or empty
status_detail, eta, delivered_atCarrier detail text, estimated delivery and delivery time (Unix timestamps)
eventsNewest first, at most 50: time, status, description, location
source, synced_at, sync_fails, notified, alertedBookkeeping

REST endpoint

POST /wp-json/siteryn-track-order/v1/track, used by the tracking form.

ParameterNotes
order_numberRequired
emailBilling email; optional for the order's signed-in owner
nonceRequired by default: wp_create_nonce( 'siteryn_track_order_lookup' )
extraExtra verification fields (for example Pro's postcode)
langWPML/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):

KeyContents
order_id, order_number, date_createdOrder id, number and Unix time
status, status_labelWooCommerce status slug and name
stage, message, notice_typeStage, status message and success / info / warning / error
timelinesteps (key, label, state complete/current/upcoming, date) and halted
shipmentsid, 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
summaryitems, item_count, total, shipping_method, ship_to (per settings)
proPro 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.

PluginTemplatesOverride folder
Freetrack-order.php, form.php, result.php, recent-orders.php, account-tracking.php, parts/notice.php, parts/timeline.php, parts/shipments.php, parts/summary.phpyourtheme/siteryn-track-order/
Proparts/shipments.php, parts/brand-header.php, parts/brand-footer.php, parts/recommendations.php, parts/ai-assistant.phpyourtheme/siteryn-track-order-pro/
Pro emailsemails/siteryn-shipment-update.php, emails/plain/siteryn-shipment-update.phpyourtheme/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

FunctionReturns
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

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.