All use cases
Commerce

Run a referral or affiliate program

Referral trees, commissions and rank progress, with the UI to show them.

The problem

Referral schemes look trivial until the second level. Who gets credit when a referred user refers someone else? What happens to a commission when the underlying payment is refunded? How does a participant see why they were paid what they were paid?

Get the arithmetic wrong and you are not fixing a bug, you are correcting people's money — which is a different kind of problem.

What you are building

Live surfaces, not screenshots — every one composed from the same components you would install.

Downline tree

fancy-mlm-ui renders unilevel, binary and matrix trees from the same JSON.

Your network6 members

Commission statement

Reversed rows are struck through and excluded from the paid total.

August statementPaid
LevelRecipientTierAmountStatus
1Ken Mbeki240.5paid
1Priya Raman198paid
2Tom Alvarez64.25pending
2Jo Fenwick31reversed
Total (paid)438.5

The code

Compute a reward per orderphp
// One computation PER REWARD, carrying level, metric and recipient -- that
// record is what a statement is rendered from months later, when somebody asks
// why a specific number is what it is.
$rewards = Mlm::computeRewards($order, [
    'levels' => [1 => 0.10, 2 => 0.05],
]);
Reverse, do not deletephp
// Refunds land after payout runs. A reversed row that stays visible -- struck
// through and excluded from the paid total -- is the difference between a
// statement someone trusts and one they dispute.
Commission::where('order_id', $order->id)
    ->where('status', '!=', 'paid')
    ->update(['status' => 'reversed', 'reversed_at' => now()]);

How to solve it

  1. Install the engine

    Referral trees with the common structures — unilevel, binary, matrix — and the commission rules that go with them.

    Run thisbash
    composer require particle-academy/fancy-mlm
  2. Record referrals as they happen

    Sign-ups attach to the referrer, building the tree as a side effect of registration rather than as a nightly reconciliation.

  3. Show participants their own numbers

    Ready surfaces for the downline tree, the commission statement and rank progress — the three things a participant asks for, and the three that generate support tickets when missing.

    Run thisbash
    npm install @particle-academy/fancy-mlm-ui