Affiliate program
The Affiliate and referral tracking module in Polski PRO gives every logged-in customer a referral link, stores the referral token in a cookie, attaches it to the next WooCommerce order and records a commission (default 5% of the order total) once the order is Processing or Completed. It records commissions but does not pay them out.
How it works
Section titled "How it works"- A logged-in customer opens the affiliate tab in My Account. On the first visit the plugin creates an affiliate record for that user with a random 12-character token and status
active - The tab shows the referral link, for example
https://example.com/?poleca=abc123def456 - A visitor opens the link. The plugin checks that the token belongs to an active affiliate and sets the
polski_affiliate_tokencookie - At checkout (classic or block) the affiliate ID is saved on the order in the
_polski_affiliate_idmeta - When the order reaches Processing or Completed, a referral row with the commission is recorded
There is no registration form, no approval step and no admin screen for affiliates.
Configuration
Section titled "Configuration"The module has its own row on Polski > Modules (module key affiliates, group Merchandising). It ships off. Saving the row writes into the polski_affiliates option.
| Setting on the row | Key | Default |
|---|---|---|
| Referral parameter in the URL | referral_param |
poleca |
| Referral cookie lifetime (days) | cookie_days |
30 (minimum 1) |
| Commission (%) | commission_percent |
5 |
| Minimum order total for a commission | minimum_order_total |
0 |
| Order statuses that earn a commission | pending_statuses |
processing,completed |
| Show an Affiliate tab in My Account | show_in_account |
on |
Other keys of the option are not on the row. Set them with WP-CLI if needed:
wp option patch update polski_affiliates account_label "Partner program"| Key | Default | Description |
|---|---|---|
account_label |
Affiliate programme | Name of the My Account tab |
dashboard_title |
Affiliate dashboard | Heading of the tab |
dashboard_intro_text |
empty | Intro text under the heading |
login_required_text |
Log in to use the affiliate programme. | Message for logged-out visitors |
referral_link_label |
Your affiliate link | Label above the link |
stats_referrals_label, stats_revenue_label, stats_commission_label |
Referrals: {count}, Sales: {amount}, Commission: {amount} | Statistic lines |
empty_text |
No referrals are attributed to your account. | Shown when there are no referrals |
column_order, column_customer, column_value, column_commission, column_status, column_date |
Order, Customer, Value, Commission, Status, Date | Table headings |
show_dashboard_title, show_dashboard_intro, show_referral_link, show_stats, show_table |
true |
Show or hide each part of the tab |
show_order_column to show_date_column |
true |
Show or hide each table column |
order_prefix |
# |
Prefix before the order number |
date_format |
d.m.Y |
Date format in the table |
Referral links
Section titled "Referral links"The link is the home page with the referral parameter:
https://example.com/?poleca=abc123def456The parameter is read on any URL of the store, so an affiliate can append ?poleca=TOKEN to a product or category link by hand. An optional campaign parameter is also read, for example ?poleca=TOKEN&campaign=newsletter.
Cookies
Section titled "Cookies"| Cookie | Value | Lifetime |
|---|---|---|
polski_affiliate_token |
Affiliate token | cookie_days |
polski_affiliate_visit |
ID of the recorded visit | cookie_days |
polski_affiliate_campaign |
Value of campaign, when present |
cookie_days |
Cookies are set with WooCommerce's wc_setcookie(). Each click on a referral link overwrites the token, so the last affiliate link clicked gets the order.
Every valid click is stored as a visit with landing URL, referrer, campaign, IP address and user agent. The link is ignored when the token is unknown, the affiliate is not active, or the logged-in visitor is the affiliate.
Commission
Section titled "Commission"The commission is order total x commission_percent / 100, where the order total is the WooCommerce order total including shipping and tax. A referral is recorded only when:
- the order carries
_polski_affiliate_id - the order is not the affiliate's own (the customer user ID differs from the affiliate's)
- the order status is in
pending_statuses - the order total is at least
minimum_order_total - no referral exists yet for that affiliate and order
The check runs when an order enters Processing or Completed, so other statuses added to pending_statuses never trigger it. The referral row keeps the order status from that moment; a later cancellation or refund does not change or remove it. There are no per-product or per-category commission rates.
My Account tab
Section titled "My Account tab"The tab lives at the polski-affiliates endpoint of My Account (for example /my-account/polski-affiliates/) and sits just above Log out. It shows:
- the referral link in a read-only field
- three numbers: referrals, total value of referred orders, total commission
- a table of referrals with order number, customer email, order value, commission, status and date
If the tab returns a 404 after enabling the module, save Settings > Permalinks once to refresh rewrite rules.
Data and hooks
Section titled "Data and hooks"The module fires no actions or filters of its own. Data is kept in the _polski_affiliate_id order meta and in these tables:
| Table | Content |
|---|---|
{prefix}polski_affiliates |
Affiliates (user, token, status) |
{prefix}polski_affiliate_referrals |
One row per referred order with total and commission |
{prefix}polski_affiliate_visits |
Recorded clicks |
{prefix}polski_affiliate_payouts |
Created by the plugin's database migration; nothing writes to it |
Common issues
Section titled "Common issues"Commission is not being recorded
Section titled "Commission is not being recorded"- Check that the module is enabled on Polski > Modules
- Verify that the
polski_affiliate_tokencookie was set (browser developer tools) - Check that the order was not placed by the affiliate's own account
- Check the order total against Minimum order total for a commission
- Check that the order reached Processing or Completed
Cookie is not being set after clicking the link
Section titled "Cookie is not being set after clicking the link"- Check that the URL parameter matches the setting (default
poleca) - Check that the token belongs to an existing affiliate
- If a page cache serves the page, add the referral parameter to the cache exclusion list, because the cookie is set by PHP on
init
How does a customer become an affiliate?
Section titled "How does a customer become an affiliate?"By opening the affiliate tab in My Account while logged in. The plugin creates an active affiliate with a token on that first visit. There is no form and no admin approval.
Does Polski PRO pay out commissions?
Section titled "Does Polski PRO pay out commissions?"No. It records the commission owed for each referred order. Paying it is up to you.
Is the commission removed when the order is refunded?
Section titled "Is the commission removed when the order is refunded?"No. The referral row is written once when the order reaches Processing or Completed and is not updated afterwards.
Can I set a different commission for some products?
Section titled "Can I set a different commission for some products?"No. One percentage from Commission (%) applies to the whole order total.