Overview
AffiliRex is a WooCommerce affiliate tracking plugin for WordPress. It attributes registrations and orders to affiliates via referral links or coupon codes, syncs order statuses with an audit trail, and provides reporting with Excel export from the WordPress admin panel.
This documentation covers installation, configuration, and the developer hooks available for customization.
Requirements
- WordPress 6.0 or later
- PHP 7.4 or later
- WooCommerce (required for order tracking and status sync)
- A valid AffiliRex license for admin settings, affiliate management, and reports
Installation
- Purchase a license and download the plugin from shop.deltadino.com.
- Upload the AffiliRex folder to wp-content/plugins/ or install via the WordPress admin panel.
- Activate the plugin. WooCommerce must be active for order features.
- Go to AffiliRex → License in the WordPress admin panel and enter your license key.
- Configure settings, create affiliates, and add triggers (slugs or coupons).
Tracking & attribution
AffiliRex supports two inbound routing modes, configurable under AffiliRex → Settings:
- Query parameter — e.g. ?ref=partner-slug (parameter name is configurable)
- Pretty URLs — e.g. /affiliate/partner-slug (base path is configurable)
- A 30-day HttpOnly cookie stores the matched affiliate and trigger
- At checkout, WooCommerce coupon triggers take priority over link/cookie attribution
- Registration conversions are captured via the user_register hook when a tracking cookie is present
Shortcodes
Display the visitor's active referral code on any page or post:
[affilirex_tracking_code]
[affilirex_tracking_code fallback="—"]
[affilirex_tracking_code field="affiliate_id"]Settings reference
- Status mapper — map WooCommerce order statuses to pending, completed, or cancelled buckets
- Routing — enable pretty links, set base path and query parameter name
- Commission basis — order total or subtotal (before tax and shipping)
Multilingual sites
AffiliRex integrates with WPML and Polylang. Query-parameter tracking works on all language variants without extra setup. Pretty-link mode registers per-language rewrite rules when a multilingual plugin is active.
Developer hooks
AffiliRex exposes 28 filters and 10 actions for deep customization. Filters run after a cache miss and before values are stored, so overrides are cached unless you opt out viaaffilirex_skip_cache. Use these hooks in a custom plugin or mu-plugin — never edit AffiliRex core files directly.
add_filter( 'affilirex_commission_amount', function( $amount, $order, $basis ) {
return $amount * 0.10; // 10% commission
}, 10, 3 );Filters (28)
Registered via apply_filters() in WordPress.
| Hook | Arguments | Description |
|---|---|---|
affilirex_skip_cache | $skip, $key | Opt out of caching for a specific cache key. |
affilirex_cache_ttl | $ttl, $key | Override the TTL for a specific cache key. |
affilirex_trigger_lookup | $trigger, $type, $value | Modify a trigger row after database lookup, before caching. |
affilirex_affiliate | $affiliate, $id | Modify an affiliate record after fetch. |
affilirex_is_affiliate_valid | $valid, $affiliate | Override active/date-range validation for an affiliate. |
affilirex_should_set_tracker | $should, $affiliate, $trigger | Allow or block writing the tracking cookie on an inbound hit. |
affilirex_tracker_cookie | $payload, $affiliate, $trigger | Modify the JSON payload stored in the tracking cookie. |
affilirex_tracker_ttl | $seconds | Change cookie lifetime (default 30 days). |
affilirex_shortcode_tracking_code | $value, $atts, $tracker | Filter output of the [affilirex_tracking_code] shortcode before escaping. |
affilirex_should_track_conversion | $should, $context | Allow or block a conversion record insert. |
affilirex_commission_amount | $amount, $order, $basis | Adjust the commission amount after subtotal/total calculation. |
affilirex_record_data | $data, $context | Modify the full record row payload before database insert. |
affilirex_default_status_mapping | $mapping | Customize WooCommerce-aware default status buckets on install. |
affilirex_mapped_status | $status, $wc_status | Override how a WooCommerce order status maps to pending/completed/cancelled. |
affilirex_status_history_entry | $entry, $record_id | Modify a status history row before insert. |
affilirex_records_query_args | $args | Adjust admin records list table query arguments. |
affilirex_export_columns | $columns, $sheet | Customize Excel export column headers (records or history sheet). |
affilirex_export_row | $row, $record | Modify a single export row before it is written. |
affilirex_export_batch_size | $size | Change rows per export batch (default 1000). |
affilirex_export_max_rows | $max | Set maximum rows per export job (default 100000). |
affilirex_export_include_history | $include | Include or exclude the Status History sheet in exports. |
affilirex_export_time_budget | $seconds | Per-batch time limit for background export jobs (default 20s). |
affilirex_current_language | $lang | Override the detected language slug for multilingual routing. |
affilirex_pretty_base | $base, $language | Set per-language pretty-link prefix (WPML/Polylang). |
affilirex_active_language_slugs | $slugs | Override the list of language slugs used for rewrite rules. |
affilirex_translate_string | $translated, $string, $context | Central override for plugin UI string translation. |
affilirex_license_is_valid | $valid | Override the final license validation result. |
affilirex_license_purchase_url | $url | Customize the purchase/renew URL shown in the license screen. |
Actions (10)
Registered via do_action() at lifecycle events.
| Hook | Arguments | Description |
|---|---|---|
affilirex_tracker_set | $affiliate_id, $trigger, $cookie | Fires after the tracking cookie is written on an inbound hit. |
affilirex_before_insert_record | $data | Fires immediately before a conversion record is inserted. |
affilirex_after_insert_record | $record_id, $data | Fires after a conversion record is successfully inserted. |
affilirex_export_started | $job_id, $filters | Fires when a background Excel export job is created. |
affilirex_export_completed | $job_id, $file_path | Fires when an export file is finalized and ready for download. |
affilirex_export_failed | $job_id, $error | Fires when an export job fails. |
affilirex_status_changed | $record_id, $old, $new, $changed_by | Fires after a record status is updated via order sync. |
affilirex_cache_invalidated | $keys | Fires after one or more cache keys are busted. |
affilirex_license_activated | $response | Fires after a license is successfully activated. |
affilirex_license_validated | $valid, $response | Fires after a remote license validation check completes. |
Need help?
Email support@deltadino.com for setup questions, license issues, or hook guidance. Active license holders receive priority support.