Advanced Affiliate Module for Magento 2
- SKU
- M2-AFFILIATE
Description / Advanced Affiliate Module for Magento 2
MAGENTO 2 · PARTNERS · COMMISSIONS · LINKS AND COUPONS
Run an affiliate program directly in Magento.
Kowal Affiliate
Connect partner registration, order attribution, and settlements with an affiliate panel. Manage links, discount codes, and commission history, and optionally use AI to support partners and promotional materials.
Partner link and code · Commissions and balance · Payout workflow
HOW IT WORKS IN PRACTICE
01 · You accept a partner
The application goes for approval and receives a referral code.
02 · You attribute the sale
A link or coupon connects the order with the affiliate.
03 · You settle the result
Commissions go through the hold period and payout handling.
What does your store gain?
Explore the module features, use cases, and settings.
1. What this module is
The module extends Magento 2 with a complete affiliate system that works directly inside the store. This means the store owner manages partners, commissions, settlements, and promotional materials from their own admin panel, while partners use their own dashboard in the customer account.
In practice, the module lets you implement several cooperation models at the same time:
- a classic affiliate program based on tracking links,
- a referral program based on individual partner codes,
- a hybrid model: affiliate link plus discount code,
- a partner program for store customers, agencies, implementation partners, and creators.
2. Main business value
The greatest value of the module is combining sales, attribution, settlements, and partner management in one place. The store does not need to maintain an external affiliate system, manually export orders, or settle partners in spreadsheets.
The module gives the store owner:
- a new sales channel,
- control over cooperation rules,
- clear commission and payout handling,
- readable reports on affiliate performance,
- the ability to prepare a program for a medium- and large-scale store after implementation validation.
The partner receives:
- their own referral code,
- their own affiliate link,
- a ready-made panel for monitoring activities,
- visibility into commissions and payouts,
- the ability to use promotional materials and banners.
3. Who the module is for
The module is suitable for stores that want to build a network of sales partners without using external affiliate platforms, or that want to keep full control over data and the settlement process.
It works especially well in projects where the affiliate program will be run by:
- customers referring the store to friends,
- online creators,
- bloggers and publishers,
- specialists and consultants,
- implementation partners,
- software houses and agencies,
- B2B resellers and sales representatives,
- brand ambassadors and communities.
4.1. Affiliate registration
The module provides an application form for the affiliate program. The customer can independently apply to join the program by providing basic contact details, a website or channel address, and a short note about the planned promotion.
After the form is submitted:
- an affiliate account is created,
- a unique
referral_codeis generated, - the application status is set to
Pending, - the administrator can receive a notification about the new application,
- the customer can receive confirmation that the application has been received.
4.2. Partner approval
The administrator can approve an affiliate from the Magento panel. After approval:
- the partner status changes to
Active, - the partner can fully use the program,
- it is possible to activate the affiliate coupon,
- the customer can receive a message confirming approval to participate.
4.3. Affiliate link
Each affiliate receives their own affiliate link based on referral_code. The link works through a tracking controller and stores visit attribution. After a click, the system can:
- save the affiliation in a cookie,
- create a visit entry,
- create an attribution entry,
- connect a later order with a specific affiliate.
4.4. Affiliate code and discount coupon
The module also supports a model where referral_code can work as a discount code in the cart.
The administrator can set the following field on the affiliate account:
Affiliate Coupon Discount (%)
If the value is greater than zero, the system:
- synchronizes the native Magento
Cart Price Rule, - sets the coupon code equal to
referral_code, - applies a percentage discount in the cart,
- treats the use of this code as the source of order affiliation.
As a result, the affiliate can promote:
- a standard affiliate link,
- the discount code itself,
- a combination of both mechanisms at the same time.
This is one of the most practical sales features of the module because many store owners expect a partner not only to drive traffic but also to give the customer a specific price benefit.
4.5. Order attribution
The module can assign an order to an affiliate based on:
- a click on an affiliate link,
- active attribution saved in the session or cookie,
- use of an affiliate code in the cart,
- a logged-in customer associated with active attribution.
The following data is stored at the order level:
affiliate_id,affiliate_attribution_id,affiliate_referral_code,is_affiliate_order,affiliate_commission_amount,affiliate_commission_status.
This makes it possible to report the sales source directly on quote and sales_order.
4.6. Commission calculation
A commission is created automatically for an affiliate order. In the current model:
- the commission is calculated as a percentage of the order subtotal,
- the default rate comes from the module configuration,
- the system avoids duplicating commissions for the same order and affiliate,
- the result is saved in the commission table and on the order.
Supported commission statuses include, among others:
pending,approved,ready_for_payout,paid,rejected,cancelled,charged_back.
4.7. Hold period and automatic approval
The module supports a commission hold period. This means the commission does not have to be ready for payout immediately. It can remain in pending status for a defined time and only after the set period expires be automatically approved by cron.
This solution is especially important for:
- return risk,
- manual order verification,
- sales models with delayed finalization,
- the need to protect the program against abuse.
4.8. Payouts for affiliates
A partner can submit a payout request if the minimum threshold has been met and they have a sufficient approved balance.
The payout workflow includes:
- submitting a payout request,
- assigning commissions to the payout,
- changing the commission status to
ready_for_payout, - marking the payout as paid,
- changing commission statuses to
paid.
This lets the store owner handle payouts in an organized and auditable way.
4.9. Fraud prevention
The module includes a basic anti-fraud layer that helps eliminate the most obvious abuse.
This includes, among other things:
- blocking self-referral,
- marking commissions as rejected when abuse is detected,
- handling fraud cases,
- recording rejection reasons,
- a separate fraud case view on the administrator side.
In addition, the module supports:
- order cancellations,
- chargebacks,
- refunds through
creditmemo, - changes to commission statuses after returns.
4.10. Notifications
The module has its own notification queueing and processing system. It can save operational events and send email messages.
Supported cases include, among others:
- new affiliate application,
- application receipt confirmation,
- affiliate approval,
- commission events,
- payouts,
- fraud alerts.
4.11. Affiliate panel
The partner uses an extensive dashboard in the Magento customer account. The dashboard is not just a list of commissions but a full operational panel.
The affiliate panel provides:
- program participation status,
- referral code,
- full affiliate link,
- default target path,
- commission summary,
- commission history,
- access to payouts,
- cooperation rules content,
- ready-made promotional snippets,
- banner preview,
- AI banner generator.
4.12. AI banner generator
The module includes an AI-supported feature that allows the affiliate to prepare a ready-made promotional banner based on a brief.
The user can provide:
- a text brief,
- visual direction,
- colors,
- style,
- an optional image URL,
- an optional target link.
The system passes to the AI layer:
- the user brief,
- referral link,
- target path,
- technical requirements for the response format.
The generated banner HTML can be saved on the affiliate account and used by the partner as ready-made promotional material.
4.13. Reporting
The module supports reports and CSV exports for key program areas:
- commissions,
- payouts,
- fraud cases,
- AI insights.
This makes both day-to-day program management and partner performance analysis easier.
5. Admin panel
The module extends the Magento admin panel with configuration and management of the affiliate program.
The administrator has access to:
- global program settings,
- commission settings,
- payout settings,
- affiliate portal settings,
- notification settings,
- fraud settings,
- AI settings,
- reporting settings.
Additionally, operational sections are available in the panel:
Affiliate Commissions,Affiliate Payouts,Affiliate Fraud Cases,Affiliate Reports.
Affiliate data is visible on the customer list and in customer editing, such as:
- program participation,
- affiliate status,
- affiliate balance,
- referral code,
- affiliate coupon discount percentage.
6.1. Affiliate link scenario
- The partner receives their link.
- The customer clicks the link and enters the store.
- The system saves the visit and attribution.
- The customer places an order.
- The order is assigned to the affiliate.
- A commission is created.
- After the hold period expires, the commission can be approved.
- After meeting the requirements, the partner can submit a payout request.
6.2. Affiliate code in cart scenario
- The partner publishes their affiliate code.
- The customer enters the code in the cart.
- Magento applies a discount from the cart rule.
- The module recognizes the code as an affiliate code.
- The order is assigned to the affiliate.
- A commission is created according to the program rules.
6.3. Hybrid scenario
The customer can first enter the store through an affiliate link and then use the affiliate discount code. This model makes it possible to combine classic tracking with benefits for the end customer.
7. Security areas
The module was prepared with production implementation in mind, so it includes:
- audit records,
- handling of returns and cancellations,
- self-referral blocking,
- notification queue,
- mechanisms limiting commission duplication,
- secure storage of AI configuration,
- limiting data sent to the AI layer,
- the ability to diagnose integration errors.
8. AI integration
The AI layer in the module is optional and does not block the basic affiliate program from operating. It can be used for:
- an affiliate assistant,
- generating insights,
- generating banners,
- product knowledge retrieval through
vector_store_id.
The module does not need to maintain its own product database for AI if the store already uses an external module that manages product knowledge and Vector Store.
9. Sales use cases
The module can be sold as a solution for several types of projects:
- B2C stores with a referral program,
- premium stores that want to build a network of brand ambassadors,
- B2B businesses with a program for sales partners,
- digital and software stores,
- agency implementations where the client needs a complete partner program without external SaaS.
Especially strong sales arguments are:
- full control over data,
- no subscription for an external affiliate platform,
- integration with Magento 2 without intermediaries,
- support for affiliate links and coupons,
- a ready partner panel,
- the ability to further extend with AI.
10. Key module advantages
The key advantages of this solution are:
- it works directly in Magento 2,
- it supports both affiliate links and affiliate codes,
- it handles discount coupons associated with the affiliate,
- it allows partner management from the Magento customer level,
- it has a real commission and payout workflow,
- it includes basic security and audit features,
- it has a modern affiliate dashboard,
- it is ready for development with additional enterprise features.
11. System requirements
The module is intended for:
- Magento Open Source / Adobe Commerce 2.4.7+
- PHP 8.2 / 8.3
It requires compatible Magento modules related to:
Customer,Quote,Sales,SalesRule,Cms,Email,Backend,Store.
12. Implementation scope
The module can be implemented in stages:
- start with affiliate links and commissions,
- extend with payouts,
- extend with affiliate coupons,
- extend with AI and content for affiliates,
- further development with more advanced commission rules and fraud scoring.
This means it is suitable both for MVP implementations and for long-term partner program development.
13. Summary
Kowal_Affiliate is an extensive affiliate module for Magento 2 that lets you sell and launch a complete partner program within your own store. It combines classic affiliate links, referral codes, discount coupons, commissions, payouts, basic fraud prevention, reporting, and a modern partner panel.
From a sales perspective, this is not just an add-on for referral links, but a complete partner layer for Magento 2 that can be offered as:
- a standalone module,
- an element of a store implementation,
- part of a growth / performance package,
- a foundation for a more advanced partner and brand ambassador program.
In practice, it is a solution that addresses the real needs of stores asking for:
- an affiliate program in Magento 2,
- discount codes for partners,
- commission settlement,
- a partner panel,
- readiness for sales and production work.
Commission and individual rate
The commission is based on the order subtotal. The affiliate account rate takes precedence over the program default rate. The partner coupon discount value and the commission percentage are separate settings.
The default configuration provides a cookie for 30 days, 10% commission, a 14-day hold period, and a payout threshold of 100. Before launch, define your own rules, currency, and return handling process.
Cart balance and settlements
The ledger records changes to the partner balance. In addition to the payout workflow, the module provides an option to use the balance as a fixed-amount discount in the cart, with amount limits, partial-use rules, and rules for combining it with coupons.
The default mode is payout_only. A payout request reserves the relevant commissions; marking it as paid confirms the workflow stage, but does not itself execute a transfer through a bank or payment operator.
Program launch and optional AI
Stores → Configuration → Affiliate Program includes settings for the program, commissions, payouts, settlement, portal, notifications, fraud, AI, and reports. Installation can add the CMS page affiliate-program without overwriting an existing page with that identifier.
AI is disabled by default. The assistant, HTML banners, and weekly insights require appropriate configuration; product knowledge uses an existing Vector Store, and the module does not synchronize it on its own.
Installation via Composer
Package kowal/module-affiliate, module Kowal_Affiliate. After configuring access to the Kowal repository, install the package, enable the module, update Magento, and clear the cache. In production, include compilation and static content deployment according to the store process.
From configuration to results
1. You accept a partner
The application goes for approval and receives a referral code.
2. You attribute the sale
A link or coupon connects the order with the affiliate.
3. You settle the result
Commissions go through the hold period and payout handling.
Partner link with a benefit for the customer
The partner shares a link and their coupon. The customer receives the configured discount, and the order is assigned to the partner.
After review and the hold period, the approved balance may qualify for a payout request. You organize the actual transfer of funds within your company settlement process.
Build a structured affiliate program
Want to adapt the module to your store? Ask about a Kowal Affiliate implementation and discuss the configuration or required extensions.
More Information
| Theme compatibility | Luma / Blank, KOWAL |
|---|
Change Log
Module Installation Instructions
Kowal_Affiliate - installation and configuration guide
This document describes how to install, activate, and perform the initial configuration of the Kowal_Affiliate module for Magento 2. The guide covers both technical requirements and practical steps needed to launch an affiliate program in your store.
1. System requirements
The module is intended for:
- Magento Open Source / Adobe Commerce 2.4.7+
- PHP 8.2 or 8.3
The Magento project should include at least the following modules:
Magento_StoreMagento_CmsMagento_CustomerMagento_EmailMagento_QuoteMagento_SalesMagento_SalesRuleMagento_Backend
2. Installation methods
The module can be deployed in the standard way as a Composer package.
2.1. Installation via Composer
The module is distributed as a Composer package. An example process looks as follows:
You will receive Composer repository access details, including the customer email address and license token, by email after purchase. They are also available in the customer panel after logging in at kowal.store. Replace TWOJ_EMAIL_KLIENTA with your account email address and TWOJ_TOKEN with the token you received. Run the commands in the Magento root directory.
composer config repositories.kowal composer https://repo.kowal.storecomposer config http-basic.repo.kowal.store 'TWOJ_EMAIL_KLIENTA' 'TWOJ_TOKEN'composer require kowal/module-affiliatebin/magento module:enable Kowal_Affiliatebin/magento setup:upgradebin/magento setup:di:compilebin/magento cache:flush2.3. Production mode
If the store runs in production mode, after installation it is also worth running:
bin/magento setup:static-content:deploy3. What the module creates during installation
During installation, the module:
- creates its own database tables related to affiliation,
- extends
quoteandsales_orderwith affiliate fields, - adds customer attributes used to manage the affiliate,
- creates the default CMS page for the partner program,
- prepares system configuration and cron jobs,
- registers email templates and admin panel resources.
3.1. Default CMS page
After installation, an example partner program page is created:
identifier: affiliate-programtitle: Affiliate Partnership ProgramThe page is universal in nature and can be used in production after minor content personalization.
The patch is idempotent:
- if a page with this
identifieralready exists, the module will not overwrite it.
4. Where to find the module configuration
The configuration panel is located under:
Stores -> Configuration -> Affiliate ProgramThe most important sections:
GeneralCommissionPayoutsAffiliate PortalNotificationsFraudAIReporting
5. Initial configuration after installation
After activating the module, the following configuration order is recommended:
- enable the module globally,
- set up affiliate registration,
- configure commission and hold period,
- set the minimum payout threshold,
- complete the affiliate portal content,
- configure administrator notifications,
- optionally configure AI,
- run a test of registration, affiliate click, and order.
6. Detailed configuration
6.1. General
Enable Module
Global module switch.
If the setting is disabled:
- affiliate tracking should not work,
- the registration form should not work,
- commissions and payouts will not be handled.
Recommendation:
Yesin the production environment after testing is complete,Noonly while disabling the program.
Enable Affiliate Registration
Enables the affiliate program application form on the store frontend.
If the option is disabled:
- new partners will not register on their own,
- the administrator can still manually mark a customer as an affiliate.
Tracking Cookie Lifetime (days)
Defines the lifetime of cookie-based attribution after clicking an affiliate link.
Examples:
30for a standard affiliate program,7for short campaigns,60or90only when the program rules provide for it.
Default Redirect Path
Fallback path used when the tracking link does not contain a valid target.
Examples:
/promotionscatalog/category/view/id/12
6.2. Commission
Enable Commissions
Enables commission calculation for affiliate orders.
If the field is disabled:
- affiliation can be saved,
- but an entry in the commission table will not be created.
Default Commission Rate (%)
Default percentage commission rate.
Example:
10means a 10% commission on the current calculation basis.
Commission Hold Period (days)
The number of days during which the commission remains in pending status.
After this period expires, cron can automatically approve the commission.
Recommendation:
14as a safe default value,0only for a very simple program with no return risk.
6.3. Payouts
Enable Payouts
Enables the payout workflow for affiliates.
If the option is disabled:
- the partner will not submit a payout request,
- the administrator can still analyze commissions but will not handle the payout in the module.
Minimum Payout Amount
Minimum balance required to request a payout.
Examples:
100250500
6.4. Affiliate Portal
This section controls the content displayed in the affiliate dashboard.
Dashboard Intro
A short description at the top of the affiliate dashboard.
It should explain to the partner:
- where to find the affiliate link,
- where to view commissions,
- how the panel works.
Program Rules
Visible cooperation rules for the affiliate.
Best practice is to enter:
- one rule per line,
- concise and clear messages.
Banner Title
Default title of the sample promotional material.
Banner Subtitle
Short description under the banner title.
Banner Target Path
Default target path for affiliate links and banners.
Examples:
/promotions/springcatalog/category/view/id/24
6.5. Notifications
Enable Notifications
Enables the internal notification system and notification queue.
Admin Notification Email
The administrator email address that should receive the most important operational messages.
If the field remains empty:
- the module can use the default Magento
generaladdress as a fallback in selected flows.
Notification Log Retention (days)
Defines how long entries in the notification log should be stored before cleanup.
6.6. Fraud
Enable Fraud Checks
Enables basic anti-fraud checks.
Block Self Referral
Blocks commission when the customer placing the order is also the affiliate associated with that order.
6.7. AI
The AI section is optional and is not required for the basic operation of the affiliate program.
Enable AI
Main switch for AI features.
OpenAI API Key
API key for communication with OpenAI.
The field is stored in encrypted configuration.
AI Model Name
Model used for AI features.
The list of models can be retrieved from OpenAI after the API key is saved correctly.
OpenAI Request Timeout (seconds)
Maximum time to wait for a response from OpenAI.
Practical recommendation:
60seconds for more stable operation in production.
Enable AI Diagnostic Logging
Enables diagnostic logging of AI requests and responses.
Useful for:
- integration,
- testing,
- analysis of timeouts and response errors.
AI Diagnostic Max Chars
Maximum length of the logged payload preview.
Enable Affiliate Assistant
Enables the affiliate assistant if the store wants to use this feature.
Enable Weekly AI Reports
Allows cyclical AI summaries to be generated.
Enable Product Knowledge Retrieval
Allows product knowledge from Vector Store to be used.
Enable Program Knowledge Retrieval
Allows knowledge about the affiliate program, FAQ, and documentation to be used.
Product Vector Store Scope
Defines how product_vector_store_id is resolved.
Product Vector Store ID
The Vector Store identifier if the store uses retrieval.
Redact Personal Data
Removes or masks personal data before sending the prompt to the AI layer.
6.8. Reporting
Enable Reporting
Enables generation of reports and CSV exports.
Export Directory
Directory path where generated exports should be saved.
Example:
var/export/affiliate7. Configuring a customer as an affiliate
After installation, the module extends Magento customer editing with affiliate fields.
In customer editing, you can manage, among other things:
Affiliate ParticipantAffiliate StatusAffiliate Referral CodeAffiliate Website URLAffiliate NotesAffiliate BalanceAffiliate Coupon Discount (%)
7.1. Affiliate Participant
Indicates whether the customer belongs to the affiliate program.
7.2. Affiliate Status
The most important statuses:
PendingActiveSuspendedRejectedBlocked
7.3. Affiliate Balance
The balance is calculated automatically from approved commissions ready for payout.
The field:
- is visible in customer editing,
- should not be edited manually,
- updates automatically after commission changes.
7.4. Affiliate Coupon Discount (%)
This field lets you assign the affiliate a discount percentage that will work on their referral_code.
If you enter a value greater than 0, the module will:
- create or update a Magento cart rule,
- set the coupon equal to the affiliate code,
- allow customers to use this code as a coupon in the cart,
- assign the order to the affiliate based on
coupon_code.
Example:
- the affiliate has the code
FMX1FBXXY3 - the administrator enters
5 - the customer enters
FMX1FBXXY3as a discount coupon - Magento applies a 5% discount
- the module assigns the order to the affiliate.
8. Module cron jobs
The module uses cron jobs in the default group.
8.1. Auto approve commissions
job: kowal_affiliate_auto_approve_commissionsschedule: */15 * * * *The task:
- checks
pendingcommissions, - changes them to
approvedafter the hold period expires.
8.2. Process notifications
job: kowal_affiliate_process_notificationsschedule: */10 * * * *The task:
- processes the notification queue,
- marks entries as sent,
- sends transactional messages for the email channel.
8.3. Cleanup notification log
job: kowal_affiliate_cleanup_notification_logschedule: 30 2 * * *The task:
- deletes old entries from the notification log according to the retention period.
8.4. Weekly AI insights
job: kowal_affiliate_generate_weekly_ai_insightsschedule: 0 6 * * 1The task:
- generates weekly AI insights if the feature is active.
9. CLI commands
The module provides service commands:
bin/magento kowal:affiliate:auto-approvebin/magento kowal:affiliate:process-notificationsbin/magento kowal:affiliate:cleanup-notificationsbin/magento kowal:affiliate:generate-ai-insightsbin/magento kowal:affiliate:export-reportThe most useful commands during initial launch are:
bin/magento kowal:affiliate:process-notificationsbin/magento kowal:affiliate:auto-approve10. First test after installation
After configuring the module, a simple end-to-end test is recommended.
10.1. Affiliate registration test
- Go to the affiliate registration form.
- Submit the application.
- Check whether the affiliate account has been created.
- Check whether the customer has the
Pendingstatus. - Check whether notification entries have been created.
10.2. Activation test
- Open customer editing in the admin panel.
- Set the affiliate status to
Activeor use the approval action. - Check whether the customer can see the affiliate dashboard.
10.3. Affiliate link test
- Copy the affiliate link from the dashboard.
- Enter the store through this link.
- Add a product to the cart.
- Place an order.
- Check whether the order has:
affiliate_idaffiliate_referral_codeis_affiliate_order = 1
10.4. Affiliate coupon test
- Set
Affiliate Coupon Discount (%)for the affiliate, for example5. - Save the customer.
- Make sure the affiliate has the
Activestatus. - Enter their
Referral Codeas a coupon in the cart. - Place an order.
- Check:
- whether the discount was applied,
- whether the order was assigned to the affiliate,
- whether a commission was created.
10.5. Payout test
- Approve the commission or wait for auto-approve.
- Check the affiliate balance.
- Submit a payout request.
- Mark the payout as paid in the admin panel.
11. Most common issues after installation
11.1. No commission after an order
Check:
- whether the order has
affiliate_id, - whether commissions are enabled,
- whether the module works after the fix for creating commissions after affiliate data is saved on the order,
- whether a record appears in the
kowal_affiliate_commissiontable.
11.2. Customer grid does not show the current affiliate balance
Check:
- whether the
customer_gridindex has been refreshed, - whether
reindexRowworks after saves, - whether the value in customer editing matches the value in the grid.
If necessary, run:
bin/magento indexer:reindex customer_grid11.3. AI does not respond
Check:
- whether
Enable AIis enabled, - whether a valid
OpenAI API Keyhas been saved, - whether a model has been selected,
- whether the timeout is not too low,
- whether
var/logdoes not show errors for the request to OpenAI.
11.4. Notifications are not being sent
Check:
- whether Magento cron jobs are running,
- whether
Enable Notificationsis active, - whether entries are saved to
kowal_affiliate_notification_log, - whether you can manually run:
bin/magento kowal:affiliate:process-notifications12. Recommended starting configuration
For the first production implementation, the following setup is recommended:
Enable Module = YesEnable Affiliate Registration = YesTracking Cookie Lifetime = 30Enable Commissions = YesDefault Commission Rate = 10Commission Hold Period = 14Enable Payouts = YesMinimum Payout Amount = 100Enable Notifications = YesBlock Self Referral = YesEnable AI = Noat the start if the store does not need AI from day one
13. Summary
After correct installation and configuration, Kowal_Affiliate lets you launch a complete partner program in Magento 2, including:
- affiliates,
- referral links,
- affiliate codes,
- affiliate discount coupons,
- commissions,
- payouts,
- notifications,
- partner dashboard,
- basic security and automation.