The free edition applies no filters. The few the full edition applies are listed at the end; most of what is useful to a developer is the data.
Tables
Both editions create the same two tables with dbDelta(); the schema version is stored in gmaf_db_version.
{prefix}gmaf_affiliates
| Column | |
|---|---|
id |
Primary key |
user_id |
WordPress user — UNIQUE |
slug |
Referral slug, first 10 characters of `wp_hash( 'gmaf-slug |
status |
pending, active or rejected |
rate |
Personal rate (full edition), empty for the shop's |
visits |
Visit counter, incremented atomically |
created_at |
UTC |
{prefix}gmaf_commissions
| Column | |
|---|---|
id |
Primary key |
affiliate_id |
The affiliate |
order_id |
The order — UNIQUE, which is what makes one order one commission |
amount |
Commission, decimal(18,6) |
basis |
Goods value it was worked out on |
rate |
Rate as frozen on the order |
status |
pending, earned, paid or reversed |
created_at, paid_at |
UTC |
A commission is written with a plain insert; a duplicate-key failure is the "already recorded" answer.
Order meta
| Key | |
|---|---|
_gmaf_referral |
Affiliate ID, written at order creation |
_gmaf_rate |
The rate string in force at that moment |
Read them with the order API ($order->get_meta( '_gmaf_referral' )), which works under HPOS and legacy storage.
// Add the referring affiliate to the admin new-order email.
add_action( 'woocommerce_email_order_meta', function ( $order, $sent_to_admin ) {
if ( $sent_to_admin && (int) $order->get_meta( '_gmaf_referral' ) > 0 ) {
echo '<p>Referred by affiliate #' . (int) $order->get_meta( '_gmaf_referral' ) . '</p>';
}
}, 10, 2 );
Cookie and links
- Cookie
gmaf_refholds the affiliate's slug; set withwc_setcookie()for 30 days (full edition:cookie_days). - Query argument
ref:https://example.com/?ref=<slug>, on any page.
My Account endpoint
- Endpoint
affiliates(/my-account/affiliates/), menu label Affiliate, placed before Log out. - Rewrite rules are flushed once; the option
gmaf_endpoint_addedrecords that. - The application form posts
gmaf_applywith a_wpnoncefor the actiongmaf_apply.
Hooks the plugin uses
| WooCommerce hook | Priority | What it does |
|---|---|---|
wp |
10 | Catches ?ref= and sets the cookie |
woocommerce_checkout_create_order |
20 | Writes the referral meta (classic checkout) |
woocommerce_checkout_order_processed |
20 | Records the commission |
woocommerce_store_api_checkout_order_processed |
20 | Attributes and records a Checkout block order |
woocommerce_order_status_changed |
20 | Earns or reverses |
woocommerce_order_refunded |
20 | Re-states an unpaid commission after a partial refund, at its frozen rate |
Options
| Option | Edition | |
|---|---|---|
gmaf_settings |
Both | Free keys enabled, rate, open; full edition adds cookie_days, attribution, earning, reversing, auto_approve, terms_page |
gmaf_db_version |
Both | Schema version |
gmaf_endpoint_added |
Both | The one-time rewrite flush |
gmaf_license |
Full | Licence state |
Filters and actions — Full edition
gmaf_settings— the merged settings array.gmaf_modules— the boot module list.gmaf_license_api_url,gmaf_update_cache_ttl,gmaf_update_retry_ttl,gmaf_sync_cache_ttl— licensing and update caching.- Action
gmaf_booted— after every module has booted; receives the container.
Cron gmaf_license_check (full edition, twice daily, only once a licence key is entered); transient gmaf_update_payload.
CSS classes (My Account)
| Class | Element |
|---|---|
.gmaf-apply |
The application form |
.gmaf-terms |
The terms link (full edition) |
.gmaf-note |
Status messages |
.gmaf-dashboard |
The dashboard wrapper |
.gmaf-link-label, .gmaf-link |
The referral link label and read-only box |
.gmaf-figures, .gmaf-figure, .gmaf-figure__label, .gmaf-figure__value |
The four totals |
.gmaf-commissions |
The commission table |
The stylesheet gmaf-account is enqueued only when the Affiliate tab is rendered.
