Advanced affiliate helper module package for HostBill.
This package is prepared in module_adv/affiliates_adv for deployment as an Other module named affiliates_adv.
Features included:
- Admin affiliate client listing
- Admin affiliate detail page
- Client-area affiliate dashboard
- Commission plans view/change
- Voucher create/list/delete
- Commission filtering and accurate SQL-based pagination
- Localization-ready labels through module
$lang
class.affiliates_adv.php- main module classadmin/class.affiliates_adv_controller.php- admin controlleruser/class.affiliates_adv_controller.php- client-area controllerapi/class.affiliates_adv_apiroutes.php- API route handlersapi/affiliates_adv_apiroutes.json- API route manifesttemplates/admin/*- admin templatestemplates/user/*- client-area templates
Deploy this package into HostBill Other modules path as:
includes/modules/Other/affiliates_adv/
Expected result:
includes/modules/Other/affiliates_adv/class.affiliates_adv.phpincludes/modules/Other/affiliates_adv/admin/class.affiliates_adv_controller.phpincludes/modules/Other/affiliates_adv/user/class.affiliates_adv_controller.phpincludes/modules/Other/affiliates_adv/api/class.affiliates_adv_apiroutes.phpincludes/modules/Other/affiliates_adv/api/affiliates_adv_apiroutes.jsonincludes/modules/Other/affiliates_adv/templates/...
After copying files:
- Open HostBill admin area.
- Go to module management / Other modules.
- Enable
affiliates_adv. - Verify admin page is available with
?cmd=affiliates_adv. - Verify client area page is available with
?cmd=affiliates_advfor logged-in clients.
Open:
?cmd=affiliates_adv
Available actions:
- list affiliate-capable clients
- filter by client ID, email, status
- activate affiliate account for a client
- open affiliate detail page
- manage commission plan
- create/delete vouchers
- filter commissions by:
order_idpaid_statusdate_fromdate_to
Open:
?cmd=affiliates_adv
Available actions:
- activate affiliate account
- review affiliate summary/stats
- choose commission plan when HostBill allows manual selection
- create/delete vouchers
- review commissions with filters
All API requests must send a bearer token header:
Authorization: Bearer $token
Base routes are defined in:
api/affiliates_adv_apiroutes.json
Handlers are implemented in:
api/class.affiliates_adv_apiroutes.php
Current routes:
GET /affiliates_adv/@client_id/infoGET /affiliates_adv/@client_id/commission-plansPOST /affiliates_adv/@client_id/commission-plan/@commission_idPOST /affiliates_adv/@client_id/vouchers/@plan_idGET /affiliates_adv/@client_id/vouchersGET /affiliates_adv/@client_id/commissions
Base header for all requests:
-H "Authorization: Bearer $token"- Method:
GET - URL:
/affiliates_adv/@client_id/info - Headers:
Authorization: Bearer $token
- Query params: none
Example:
curl -X GET \
-H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/info"Sample response:
{
"success": true,
"affiliate": {
"id": 10,
"client_id": 123,
"status": "Active",
"balance": "25.00",
"currency_id": 1,
"landingpage": "https://your-hostbill.example/landing-page",
"referral_url": "https://your-hostbill.example/?affid=10"
}
}- Method:
GET - URL:
/affiliates_adv/@client_id/commission-plans - Headers:
Authorization: Bearer $token
- Query params:
voucher_enabled=1optional
Example:
curl -X GET \
-H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/commission-plans?voucher_enabled=1"Sample response:
{
"success": true,
"commisions": [
{
"id": 3,
"name": "Default plan",
"type": "Percent",
"rate": "10%",
"enable_voucher": 1
}
]
}- Method:
POST - URL:
/affiliates_adv/@client_id/commission-plan/@commission_id - Headers:
Authorization: Bearer $token
- Body: none required
Example:
curl -X POST \
-H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/commission-plan/3"Sample response:
{
"success": true,
"commission_id": 3
}- Method:
POST - URL:
/affiliates_adv/@client_id/vouchers/@plan_id - Headers:
Authorization: Bearer $token
- Body params:
codediscountcycleexpiresmax_usageaudience
Example:
curl -X POST \
-H "Authorization: Bearer $token" \
-d "code=AFFWELCOME10" \
-d "discount=10" \
-d "cycle=once" \
-d "expires=2026-12-31" \
-d "max_usage=100" \
-d "audience=new" \
"https://your-hostbill.example/api/affiliates_adv/123/vouchers/3"Sample response:
{
"success": true,
"voucher_id": 55
}- Method:
GET - URL:
/affiliates_adv/@client_id/vouchers - Headers:
Authorization: Bearer $token
- Query params: none
Example:
curl -X GET \
-H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/vouchers"Sample response:
{
"success": true,
"vouchers": [
{
"id": 55,
"code": "AFFWELCOME10",
"value": "10",
"cycle": "once",
"max_usage": 100,
"num_usage": 0
}
]
}- Method:
GET - URL:
/affiliates_adv/@client_id/commissions - Headers:
Authorization: Bearer $token
- Query params:
order_idpaid_status=paid|unpaiddate_from=YYYY-MM-DDdate_to=YYYY-MM-DDpageperpageorderby
Example:
curl -X GET \
-H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/commissions?paid_status=paid&date_from=2026-01-01&date_to=2026-12-31&page=1&perpage=20&orderby=date_created|DESC"Sample response:
{
"success": true,
"orders": [
{
"id": 901,
"order_id": 4001,
"commission": "15.00",
"paid": 1,
"date_created": "2026-04-10 09:30:00",
"firstname": "John",
"lastname": "Doe",
"total": "150.00"
}
],
"pagination": {
"perpage": 20,
"totalpages": 3,
"sorterrecords": 45,
"sorterpage": 0
}
}Example:
curl -H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/info"Example with filters:
curl -H "Authorization: Bearer $token" \
"https://your-hostbill.example/api/affiliates_adv/123/commissions?paid_status=paid&page=1&perpage=20"Notes:
$tokenis the UserApi JWT token.- Without this header, authentication should fail before route execution.
Supported query params for commissions:
order_idpaid_status=paid|unpaiddate_from=YYYY-MM-DDdate_to=YYYY-MM-DDpageperpageorderby(examples:id|DESC,date_created|ASC,commission|DESC)
Response includes:
orderspagination.perpagepagination.totalpagespagination.sorterrecordspagination.sorterpage
- This package is authored in
module_advbut runtime template/controller paths expect deployment underincludes/modules/Other/affiliates_adv. - Accurate commission pagination is implemented by filtering and counting directly in SQL before loading detailed commission rows.
- If your HostBill build injects controller helper properties during controller bootstrap,
public $affiliate;is already declared for compatibility.
Reference architecture used:
module_adv/locations_v2
Business logic sources reused conceptually from HostBill core:
includes/modules/Site/affiliates/models/class.affiliates_user_model.phpincludes/components/affiliate/class.affiliate.php