Affiliate program
The affiliate program module lets you run a referral program in the store. Affiliates share referral links, and the plugin tracks conversions and calculates commissions.
How it works
Section titled “How it works”- A customer registers as an affiliate in the My Account panel
- The administrator activates the affiliate account
- The affiliate receives a unique token and referral link
- The affiliate shares the link (e.g. on social media, on a blog)
- A visitor clicks the link - the token is saved in a cookie
- The visitor places an order - the plugin associates the order with the affiliate
- After the order is paid, the plugin calculates the commission
Configuration
Section titled “Configuration”Go to WooCommerce > Settings > Polski > PRO Modules > Affiliate program.
The module is controlled by the option:
polski_affiliatesGeneral settings
Section titled “General settings”| Setting | Description |
|---|---|
| Enable affiliate program | Activates the module |
| Commission rate (%) | Percentage commission on order value (default 10%) |
| Commission basis | Net amount / Gross amount / Net amount excluding shipping |
| Cookie duration (days) | How many days the token cookie is valid (default 30) |
| Automatic activation | Automatically activate new affiliates (default: disabled) |
| Minimum payout | Minimum commission amount for payout |
| URL parameter | Name of the parameter in the referral link (default poleca) |
Per-product commission rates
Section titled “Per-product commission rates”In addition to the global commission rate, the administrator can set an individual rate for a specific product. In the product editor, under the “Affiliate program” section:
- Commission rate (%) - overrides the global rate
- Exclude from program - the product does not generate commissions
Per-category commission rates are also supported - a setting on a category applies to all products in that category, unless a product has its own rate.
Referral links
Section titled “Referral links”Link format
Section titled “Link format”The referral link contains a URL parameter with the affiliate token:
https://example.com/?poleca=abc123def456The poleca parameter is configurable. The token is a unique affiliate identifier generated upon registration.
Cookie tracking
Section titled “Cookie tracking”After clicking a referral link, the plugin sets a cookie:
| Parameter | Value |
|---|---|
| Cookie name | polski_affiliate_token |
| Value | Affiliate token |
| Lifetime | Configurable (default 30 days) |
| Path | / |
| SameSite | Lax |
The cookie is set server-side (PHP) with the HttpOnly flag. On subsequent visits, the plugin checks for the cookie and associates any order with the affiliate.
Order attribution
Section titled “Order attribution”The plugin uses a “last click” attribution model - if a customer clicked links from multiple affiliates, the commission goes to the last one. The cookie is overwritten with each new link click.
Affiliate registration and activation
Section titled “Affiliate registration and activation”Registration
Section titled “Registration”A customer can register as an affiliate in the My Account panel at /moje-konto/polski-affiliates/. The registration form contains:
- first and last name (fetched automatically from the account)
- commission payment method (bank transfer / discount code)
- bank account number (for bank transfer)
- consent to the affiliate program terms
Activation
Section titled “Activation”By default, new affiliate accounts require manual activation by the administrator. The administrator receives an email notification about a new registration and can:
- activate the account in the WooCommerce > Affiliates panel
- reject the registration with a reason
Optionally, automatic activation can be enabled - new accounts become active immediately after registration.
Affiliate statuses
Section titled “Affiliate statuses”| Status | Description |
|---|---|
| Pending | Awaiting activation |
| Active | Active - can generate links and earn commissions |
| Suspended | Suspended by the administrator |
| Rejected | Rejected - registration denied |
Commission tracking
Section titled “Commission tracking”Commission calculation
Section titled “Commission calculation”Commissions are calculated automatically after a paid order is associated with an affiliate. Commissions are not calculated for:
- cancelled or refunded orders
- orders placed by the affiliate themselves (self-referral)
- products excluded from the program
Commission statuses
Section titled “Commission statuses”| Status | Description |
|---|---|
| Pending | Calculated, awaiting approval |
| Approved | Approved, ready for payout |
| Paid | Paid out |
| Rejected | Rejected (e.g. order refunded) |
Automatic approval
Section titled “Automatic approval”Commissions change status from “Pending” to “Approved” after a configurable period (default 14 days). The delay protects against commissions from orders that may be refunded.
If an order is cancelled or refunded during the waiting period, the commission is automatically rejected.
My Account panel
Section titled “My Account panel”The module adds a /polski-affiliates endpoint to the My Account panel. The endpoint is available at:
/moje-konto/polski-affiliates/Affiliate dashboard
Section titled “Affiliate dashboard”After account activation, the affiliate sees a dashboard with:
- Statistics - total clicks, orders, commissions
- Referral link - full link with a copy button
- Commissions - list of commissions with dates, amounts and statuses
- Payouts - payout history
- Monthly statistics - clicks and conversions chart
Link generation
Section titled “Link generation”The affiliate can generate a referral link to:
- the store homepage
- a specific product
- a product category
- any page within the store domain
Each link contains the poleca parameter with the affiliate token.
Admin panel
Section titled “Admin panel”Affiliate list
Section titled “Affiliate list”Go to WooCommerce > Affiliates. The table contains:
- first and last name
- status
- registration date
- number of referrals
- total commission
- payout balance
Commission management
Section titled “Commission management”Go to WooCommerce > Affiliates > Commissions. The administrator can:
- browse the commission list with filters (affiliate, status, date)
- approve or reject commissions
- mark commissions as paid
- export commissions to CSV
Report
Section titled “Report”Go to WooCommerce > Affiliates > Report. The report contains:
- total value of referred orders
- total commission amount
- conversion rate (clicks -> orders)
- top 10 affiliates
- monthly trend
polski_pro/affiliate/commission_created
Section titled “polski_pro/affiliate/commission_created”Action fired after a commission is calculated.
/** * @param int $commission_id ID prowizji * @param int $affiliate_id ID afilianta * @param int $order_id ID zamówienia * @param float $amount Kwota prowizji */do_action('polski_pro/affiliate/commission_created', int $commission_id, int $affiliate_id, int $order_id, float $amount);Example:
add_action('polski_pro/affiliate/commission_created', function (int $commission_id, int $affiliate_id, int $order_id, float $amount): void { // Powiadomienie afilianta o nowej prowizji $affiliate = get_userdata($affiliate_id); wp_mail( $affiliate->user_email, 'Nowa prowizja w programie afiliacyjnym', sprintf( 'Otrzymałeś prowizję %.2f zł za zamówienie #%d.', $amount, $order_id ) );}, 10, 4);polski_pro/affiliate/registered
Section titled “polski_pro/affiliate/registered”Action fired after a new affiliate registers.
/** * @param int $user_id ID użytkownika * @param string $token Wygenerowany token afilianta */do_action('polski_pro/affiliate/registered', int $user_id, string $token);Example:
add_action('polski_pro/affiliate/registered', function (int $user_id, string $token): void { // Przypisanie roli WordPress $user = get_userdata($user_id); $user->add_role('affiliate');}, 10, 2);polski_pro/affiliate/validate_referral
Section titled “polski_pro/affiliate/validate_referral”Filters the referral validation before commission calculation.
/** * @param bool $is_valid Czy polecenie jest prawidłowe * @param int $affiliate_id ID afilianta * @param int $order_id ID zamówienia */apply_filters('polski_pro/affiliate/validate_referral', bool $is_valid, int $affiliate_id, int $order_id): bool;Example:
add_filter('polski_pro/affiliate/validate_referral', function (bool $is_valid, int $affiliate_id, int $order_id): bool { $order = wc_get_order($order_id);
// Blokowanie self-referral po adresie e-mail $affiliate_email = get_userdata($affiliate_id)->user_email; if ($order->get_billing_email() === $affiliate_email) { return false; }
return $is_valid;}, 10, 3);Common issues
Section titled “Common issues”Commission is not being calculated
Section titled “Commission is not being calculated”- Check if the affiliate has “Active” status
- Verify that the
polski_affiliate_tokencookie is set (browser developer tools) - Check if the order was not placed by the affiliate themselves
- Verify that the products in the order are not excluded from the program
Cookie is not being set after clicking the link
Section titled “Cookie is not being set after clicking the link”- Check if the URL parameter is correct (default
poleca) - Verify that the affiliate token exists and is active
- Check if caching plugins are caching the page with URL parameters - add the
polecaparameter to the cache exclusion list
Affiliate does not see the panel in My Account
Section titled “Affiliate does not see the panel in My Account”- Check if the affiliate module is enabled
- Go to Settings > Permalinks and click “Save” (refreshes rewrite rules)
- Verify that the
polski-affiliatesendpoint is registered