Skip to content

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.

  1. 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
  2. The tab shows the referral link, for example https://example.com/?poleca=abc123def456
  3. A visitor opens the link. The plugin checks that the token belongs to an active affiliate and sets the polski_affiliate_token cookie
  4. At checkout (classic or block) the affiliate ID is saved on the order in the _polski_affiliate_id meta
  5. 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.

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:

Terminal window
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

The link is the home page with the referral parameter:

https://example.com/?poleca=abc123def456

The 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.

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.

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.

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.

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
  1. Check that the module is enabled on Polski > Modules
  2. Verify that the polski_affiliate_token cookie was set (browser developer tools)
  3. Check that the order was not placed by the affiliate's own account
  4. Check the order total against Minimum order total for a commission
  5. Check that the order reached Processing or Completed
Section titled "Cookie is not being set after clicking the link"
  1. Check that the URL parameter matches the setting (default poleca)
  2. Check that the token belongs to an existing affiliate
  3. 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.

This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.