explaingit

agentpietrucha/ks_affiliation

1PHPAudience · developerComplexity · 3/5ActiveSetup · moderate

TLDR

PrestaShop 8 module that tracks affiliate links via cookie attribution, ties orders back to the referring code, and shows per-link dashboards with payout and refund tracking.

Mindmap

mindmap
  root((ks_affiliation))
    Inputs
      Affiliate token URL
      Cookie
      PrestaShop order events
    Outputs
      Linked order rows
      Per-link dashboard
      Payout totals
    Use Cases
      Pay affiliates a percentage
      Track campaign clicks
      Audit returns by affiliate
      Run multi-store attribution
    Tech Stack
      PHP
      PrestaShop
      MySQL
      JavaScript

Things people build with this

USE CASE 1

Create named affiliate links with custom codes and share ?affiliate_token=... URLs

USE CASE 2

Attribute orders back to the referring affiliate via an httpOnly SameSite cookie

USE CASE 3

Track per-link totals for completed orders, returns, and payout percentages

USE CASE 4

Run the module in a PrestaShop multi-store setup with per-shop attribution

Tech stack

PHPPrestaShopMySQLJavaScript

Getting it running

Difficulty · moderate Time to first run · 1h+

Needs PrestaShop 8.0 to 8.9.x and PHP 8.0 or newer, and two known bugs (Copy button, edit-creates-new) still exist in 1.0.4.

In plain English

KS Affiliation is a module for the PrestaShop 8 e-commerce platform that tracks affiliate links. The shop owner creates a named link with a code, shares URLs that include that code, and when a visitor clicks through, the module drops a cookie on their browser. If the visitor later places an order on the same store, the module records that the order belongs to that affiliate. Prerequisites are PrestaShop 8.0 through 8.9.x, PHP 8.0 or newer, and it works in multi-store setups. The module has two places where settings live. Global configuration sits under Modules > Module Manager and only has two knobs: which order state counts as a finished, paid, shipped order, and a Delay in days that adds onto PrestaShop's Merchandise Returns time limit before an order is treated as Completed. Per-link settings sit under Catalog > Affiliate Links and include a description, cookie lifespan, an optional payout percentage, an Active toggle, and the affiliate code itself. Codes are 3 to 64 alphanumeric characters, can be custom or auto-generated, and are locked once the link exists. Sharing a link is just adding ?affiliate_token=<code> to any store URL. On click the module sets an httpOnly, SameSite=Lax cookie for the configured lifespan, strips the token from the address bar with a server redirect and a JavaScript fallback, and leaves the visitor on the page they asked for. Multi-store is strict: a token created on Store A only attributes orders placed on Store A. When an order is validated, the module reads the cookie, looks up the link on the same shop, and writes one row into ks_affiliation_order linking the order to the affiliate. Each link has a View Orders dashboard with four panels: total completed orders amount, total orders amount, total returns amount, and total payout, all excluding shipping. Each order gets a status badge: Completed when there are no refunds and enough time has passed, Returned when every unit is refunded, Partially Completed when some units came back, and Awaiting for everything else. A manual Finished checkbox on each order is for the admin's own bookkeeping. The data model uses two tables, both dropped on uninstall. Current version is 1.0.4. The README lists two known bugs: the Copy button on affiliate URLs sometimes does not work, and editing a link creates a new one instead of updating it.

Copy-paste prompts

Prompt 1
Walk me through installing ks_affiliation on PrestaShop 8.1 with PHP 8.2
Prompt 2
Explain how the Delay in days setting interacts with PrestaShop's Merchandise Returns time limit
Prompt 3
Show me the ks_affiliation_order table schema and how it links back to orders
Prompt 4
Help me work around the known bug where editing an affiliate link creates a new one instead of updating it
Prompt 5
Tell me how multi-store strict attribution behaves when the same token is reused across shops
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.