Developer reference
Hooks for integrating Leet Order Tracking with other plugins and custom code. All hooks are WordPress filters; add them in a small custom plugin or your child theme’s functions.php.
leet_ot_tracking_info#
Supplies the tracking number, carrier and link shown for an order. Use it when tracking data lives somewhere else, for example in another shipping plugin’s meta. Whatever the filter returns is rendered; the url can be left empty to show the number without a link.
add_filter( 'leet_ot_tracking_info', function ( array $info, WC_Order $order ) {
$number = $order->get_meta( '_my_shipping_plugin_tracking_number', true );
if ( '' !== $number ) {
$info['number'] = $number;
$info['carrier'] = 'DHL';
// Reuse the carrier templates from the settings screen:
$info['url'] = Leet_OT_Settings::carrier_url( $info['carrier'], $info['number'] );
}
return $info;
}, 10, 2 );
| Parameter | Type | Description |
|---|---|---|
$info | array | array( 'number' => string, 'carrier' => string, 'url' => string ) as read from the order meta and the carrier settings |
$order | WC_Order | The order being displayed |
Other filters#
| Filter | Parameters | Purpose |
|---|---|---|
leet_ot_settings | $settings (array) | The plugin settings after defaults are applied. Force a setting regardless of what is saved. |
leet_ot_status_remarks | $defaults (array of slug => array( 'label', 'remark', 'eta' )) | The default label, remark and ETA per status, before the merchant’s saved settings are applied. Add defaults for your own custom statuses. |
leet_ot_status_texts | $texts (array), $status (string) | The final label, remark and ETA used for one status on the result card. |
leet_ot_carrier_url | $url (string), $carrier (string), $tracking_number (string) | The carrier tracking link after the template has been filled in. Return '' for no link. |
leet_ot_render_order | $output (string), $order (WC_Order) | The complete HTML of the result card. Append or replace markup. |
leet_ot_max_failed_attempts | $max (int, default 10) | Failed lookups allowed per visitor and per order number within 15 minutes. |
leet_ot_trust_proxy | $trust (bool, default from LEET_OT_TRUST_PROXY) | Whether forwarded IP headers are trusted for rate limiting. |
woocommerce_shortcode_order_tracking_order_id | $order_number | WooCommerce core filter, applied to the entered order number to resolve it to an order ID. Custom order number plugins already hook it. |
Example: add a default remark for a custom “Out for delivery” status registered by another plugin.
add_filter( 'leet_ot_status_remarks', function ( array $defaults ) {
$defaults['out-for-delivery'] = array(
'label' => 'Out for delivery',
'remark' => 'Your parcel is with the courier and will arrive today.',
'eta' => 'Today',
);
return $defaults;
} );
Example: raise the rate limit on an intranet store.
add_filter( 'leet_ot_max_failed_attempts', function () {
return 25;
} );
Constants#
| Constant | Where | Purpose |
|---|---|---|
LEET_OT_TRUST_PROXY | wp-config.php | Set to true to trust forwarded IP headers for rate limiting (see Privacy and rate limiting). |
LEET_OT_VERSION | Defined by the plugin | Current plugin version, useful for cache busting in your own code. |
Data reference#
| Item | Key |
|---|---|
| Settings option | leet_ot_settings (array with statuses, fields, carriers, carrier_url_template) |
| Tracking number order meta | _leet_ot_tracking_number |
| Carrier order meta | _leet_ot_carrier |
| Failed-lookup counters | Transients leet_ot_fail_{hash}, 15-minute lifetime |
| Shortcodes | leet_order_tracking, order_tracking (alias, only when free) |
| Front-end stylesheet handle | leet-ot-frontend |
| Text domain | leet-order-tracking |
Was this article helpful?
Tell us what was missing
