Black Friday: 79% off every plugin Shop the sale →

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 );
ParameterTypeDescription
$infoarrayarray( 'number' => string, 'carrier' => string, 'url' => string ) as read from the order meta and the carrier settings
$orderWC_OrderThe order being displayed

Other filters#

FilterParametersPurpose
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_numberWooCommerce 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#

ConstantWherePurpose
LEET_OT_TRUST_PROXYwp-config.phpSet to true to trust forwarded IP headers for rate limiting (see Privacy and rate limiting).
LEET_OT_VERSIONDefined by the pluginCurrent plugin version, useful for cache busting in your own code.

Data reference#

ItemKey
Settings optionleet_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 countersTransients leet_ot_fail_{hash}, 15-minute lifetime
Shortcodesleet_order_tracking, order_tracking (alias, only when free)
Front-end stylesheet handleleet-ot-frontend
Text domainleet-order-tracking
Was this article helpful?