How Gatemi Affiliates Works

Four rules

  1. A commission is decided once, when the order is created, and frozen onto it. The affiliate and the rate are written to the order at the checkout and never worked out again. Otherwise lowering your rate would silently shrink every pending payout — including for sales made under the old terms.
  2. One order is one commission. The commissions table has a UNIQUE (order_id) index, and that index is the check. WooCommerce fires its status hooks more than once in normal operation; a "look first, then insert" check in PHP loses that race on a busy day and pays somebody twice.
  3. Only the goods count, and only a paid order earns. Commission is worked out on the order's line items, net of refunds — not on shipping, which is the courier's money, and not on tax, which is the tax authority's. It is waiting until the order is paid.
  4. Nobody is paid for their own order. Checked twice: the customer account that placed the order, and the billing email on it.

1. The visit

An affiliate's link is your home page with ?ref=<slug> on it. The slug is a hash of the affiliate's account, not their username — a link is shared in public, and one carrying usernames is a list of accounts to try passwords against. A link to another page also works: add ?ref=<slug> to any address on your site.

When somebody opens it, the plugin looks the slug up:

  • If it belongs to nobody, or the affiliate is not active (pending, rejected or suspended), nothing happens. An unapproved account cannot start building a balance by handing out links.
  • If the visitor already has a referral cookie and attribution is "first", nothing changes.
  • Otherwise the affiliate's Visits count goes up by one (one atomic visits = visits + 1) and the cookie gmaf_ref is set for 30 days (Full edition: the number of days you set).

2. The order

When the order is created — woocommerce_checkout_create_order on the classic checkout, woocommerce_store_api_checkout_order_processed on the Checkout block — the plugin reads the cookie. If it names an active affiliate who is not the customer, it writes onto the order:

  • _gmaf_referral — the affiliate's ID,
  • _gmaf_rate — the rate as it stands now (Full edition: the affiliate's own rate if set, else the shop's).

Right after, a commission row is inserted: the amount, the basis it was worked out on, the rate, and the status pending ("Waiting on payment").

3. The arithmetic

The basis is the sum of the order's line totals — each product line after coupon discounts, without tax — minus anything already refunded on that line, never below zero. Shipping, fees and tax are not in it.

  • A rate with % is that share of the basis, capped at 100%.
  • A rate without % is that flat amount, once per order.

Amounts are rounded to two decimals.

4. The order is paid

When the order's status changes to Processing or Completed (Full edition: the statuses in Earned at these statuses), the commission moves from pending to earned. Only from pending: a commission that has already been paid out is never earned twice.

An order that reaches a paid status without going through the checkout — for example one created by hand — has its commission recorded at that moment instead, if it carries the referral meta.

5. Refunded, cancelled or failed

When the order's status changes to Refunded, Cancelled or Failed (Full edition: the statuses in Reversed at these), a pending or earned commission becomes reversed. It is never deleted, so the affiliate can see what happened to a sale they were told about. A commission already marked paid is never reversed — that would make the ledger disagree with your bank.

A partial refund leaves the order's status where it was, so the plugin listens for the refund itself (woocommerce_order_refunded) and re-states a pending or earned commission on the goods left, at the rate frozen on the commission row — never at today's rate. A £100 order at 10% refunded down to £40 pays £4. A commission already paid is never rewritten, and a refund of everything is left to the status change above.

6. Paying out

Record payout on the affiliate's row (both editions) marks all their earned commissions as paid, with the date. You send the money yourself, by bank transfer, PayPal or however you pay people. The plugin has no gateway and never asks for a credential that could move money.

Commission statuses

Status Shown to the affiliate as Meaning
pending Waiting on payment Order placed, not yet paid
earned Earned Order paid; owed to the affiliate
paid Paid out Recorded as paid
reversed Reversed Order refunded, cancelled or failed

The affiliate's dashboard

My Account → Affiliate shows a signed-in affiliate their referral link, visits, the totals waiting, earned and paid out, and their last 50 commissions by date (in the shop's own timezone), amount and status. It deliberately does not show the order number, the customer or what was bought: an affiliate is owed a figure, not a copy of your order book. The page finds the affiliate by the signed-in account, never by anything in the URL.

Worked example

The shop rate is 10%. Sam is approved and shares their link. A visitor arrives through it on 1 March and orders on 10 March: two items at £40 and £20, a £10 coupon, £5 shipping and VAT.

  • Basis: £40 + £20 − £10 = £50 (shipping and VAT excluded).
  • Commission: 10% of £50 = £5.00, pending.
  • On 11 March the order is completed → earned.
  • In April the shop changes its rate to 8%. Sam's £5.00 stays £5.00.
  • At the end of April the shop pays Sam and presses Record payout → paid.
Shopping Cart
Scroll to Top