=== NetAffiliates ===
Contributors: netchameleon
Tags: affiliate, referral, woocommerce, commission, partners
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Run your own affiliate programme: tracked links and coupons, commission on WooCommerce sales, approval before you pay, and payouts.

== Description ==

NetAffiliates lets you turn happy customers, bloggers and local partners into a sales team, without paying a monthly platform fee or a cut of every sale. Everything runs on your own WordPress site.

Partners apply on your site, get their own link (and a coupon code if you like), and see their clicks, sales and earnings in a dashboard. When their link or coupon brings in a WooCommerce order, they earn commission. Sales wait until your refund window has passed, so you never pay out on a refund, and you pay partners in batches with a CSV for your bank or PayPal.

= Referral links and coupons =

* Each partner gets a link like `example.com/?ref=sam-k`, for any page on your site. Partners can make links to any page from their dashboard.
* Give a partner a WooCommerce coupon and every order using it is credited to them, even if the customer never clicked their link.
* A cookie remembers the partner for 30 days (you choose). Choose whether the first or the last partner's link wins.
* Partners can't earn commission on their own orders.
* Works with page caching: visits are recorded through the WordPress REST API.

= Commission =

* A default rate for everyone: a percentage of the sale, or a fixed amount per order.
* A partner's own rate, for your best partners.
* A product's own rate (a percentage, or a fixed amount per item), set on the product.
* Worked out on items after discounts, without tax or shipping (both optional).

= Approval and refunds =

* Sales are saved as Pending when the order is paid (Processing or Completed, you choose).
* They are approved automatically once your refund window has passed (30 days by default), or by you.
* A refund lowers the commission. A full refund or cancellation rejects it. If a refund comes after you have already paid, the referral is flagged for you to sort out; nothing is taken back automatically.

= Payouts =

* Choose which approved referrals to pay, with a minimum per partner. Partners below it roll over to next time.
* Export a CSV for your bank or PayPal's mass payment upload, send the money, then mark the payout as paid. Partners get an email.
* Bank details are never stored on your site. Partners choose PayPal (an email address) or bank transfer, and you keep bank details in your banking app.

= Partner sign-up and dashboard =

* A sign-up form with your partner terms. The exact wording each partner agreed to is kept, with the time.
* Spam checks with no puzzles: a hidden honeypot field, a timing check and a limit per visitor.
* New applicants get an account and WordPress's "set your password" email. Approve them yourself, or automatically.
* A dashboard where partners see their link, coupon, clicks, sales, earnings, what's waiting for approval and what's ready to pay, a 12-month chart, their referrals and their payouts. Partners never see your customers' names.

= In your dashboard =

* Overview: sales from partners, commission, clicks and conversion, a 12-month chart, top partners, and a "Needs you" list.
* Affiliates, Referrals, Visits and Payouts screens, with search, filters and bulk actions.
* Emails: new applications to you; welcome, sale and payout emails to partners. Each can be turned off.

= Privacy and cookie consent =

* If NetCookies by Netchameleon is active, the referral cookie is only set when the visitor accepts Marketing cookies, and it is listed in your cookie declaration. Visits are still counted, and coupons still credit partners.
* IP addresses are never stored, only a one-way scrambled version used to count each visit once.
* Works with WordPress's Export Personal Data and Erase Personal Data tools.
* Old visits are deleted automatically (after 90 days by default).
* Suggested text for your privacy policy is added to Settings → Privacy.
* NetAffiliates makes no requests to other servers.

= NetAffiliates Pro =

Pro adds recurring commission on WooCommerce Subscriptions renewals, tiered and category rates, lifetime customers, PayPal payouts in one click, banners and text links for partners, sub-IDs and fraud checks. You'll see where each one would go, greyed out, in the free plugin. The free plugin is complete on its own and has no limits on partners or sales.

== Installation ==

1. Install and activate NetAffiliates. WooCommerce needs to be active for sales to be credited.
2. Make a page for partners to apply, with the **Affiliate sign-up** block (or `[netaffiliates_signup]`).
3. Make a page for their dashboard, with the **Affiliate dashboard** block (or `[netaffiliates_dashboard]`).
4. Go to Netchameleon → NetAffiliates → Settings to set your commission rate, refund window and partner terms.
5. Approve applications on the Affiliates screen. Each partner gets an email with their link.

== Frequently Asked Questions ==

= Does it need WooCommerce? =

To credit sales, yes. Links, visits, partner sign-up and the dashboard work without it.

= Does it work with the block checkout? =

Yes, with both the classic and the block checkout, and with High-Performance Order Storage.

= What if a customer uses a partner's coupon and another partner's link? =

The coupon wins. Between two links, the last one clicked wins unless you choose "first link wins" in Settings → Tracking.

= Can a partner be paid for their own order? =

No. If the buyer's account or billing email belongs to the partner, the referral is rejected.

= Can I pay partners through PayPal automatically? =

In the free plugin you export a CSV and send the money yourself. NetAffiliates Pro can pay PayPal partners in one go.

= Who can manage the programme? =

Shop managers and administrators. Settings are for administrators. Developers can change this with the `netaff_capability` filter.

= Is anything deleted when I uninstall? =

No, unless you tick "Also delete all affiliates, referrals, visits and payouts" in Settings → Advanced first.

= Can developers extend it? =

Yes. Filters: `netaff_settings`, `netaff_referral_commission`, `netaff_integrations` (add other sources of sales), `netaff_email` and `netaff_capability`. Actions: `netaff_visit_logged`, `netaff_referral_saved`, `netaff_referral_status_changed`, `netaff_affiliate_created`, `netaff_affiliate_status_changed`, `netaff_application` and `netaff_payout_paid`. Add-ons can add settings with `net_netaffiliates_settings_tabs` and `netaff_settings_rows_{tab}`, and `net_netaffiliates_is_pro` hides the Pro previews.

== External services ==

NetAffiliates does not connect to any external service. The "Learn more" links in the dashboard open netchameleon.co.uk in a new tab only when you click them.

== Screenshots ==

1. Overview: sales, commission, clicks and what needs your attention.
2. Affiliates, with each partner's link, coupon, rate and earnings.
3. Referrals waiting for the refund window, with approve and reject.
4. Creating a payout, with a minimum per partner.
5. The partner dashboard on your site.
6. The partner sign-up form.

== Changelog ==

= 1.0.1 =
* Fix: WooCommerce Subscriptions renewal orders are no longer credited by accident (Subscriptions copies the first order's details onto renewals).
* New hooks for add-ons: partner dashboard tabs and link builder fields, affiliate screen sidebar, payout actions and locks, auto-approval, table notes.

= 1.0.0 =
* First release: referral links and coupons, commission on WooCommerce orders (default, partner and product rates), approval after the refund window, refunds, payouts with CSV, partner sign-up and dashboard with blocks and shortcodes, emails, NetCookies consent, privacy tools.
