OrderAffiliates extends OrderModel
Order Affiliate Management
Table of Contents
Methods
| add() | Add an affiliate |
| affiliateMonthlyReport() | Send a affiliate email report for the previous month. |
| delete() | Permanently deletes the given affiliate |
| edit() | Edit an affiliate |
| get() | Fetches the affiliate with the given ID |
| getAffiliateDaysActive() | Get the number of days an affiliate has been active |
| getAll() | Returns all affiliates in the system for the given company |
| getByClientId() | Fetches the affiliate with the given client ID |
| getByCode() | Fetches the affiliate with the given code |
| getList() | Returns a list of affiliates for the given company |
| getListCount() | Returns the total number of affiliate for the given company |
| getStatusCount() | Retrieves the number of affiliates given an affiliate status |
| getStatuses() | Returns all supported affiliate statuses in key/value pairs |
| getAffiliate() | Returns a partial affiliate query |
| getRules() | Returns all validation rules for adding/editing affiliates |
Methods
add()
Add an affiliate
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of input data including:
- client_id The ID of the client to associate the affiliate with
- code The code to use when creating referral links for this affiliate (optional)
- status The status of the affiliate ('active' or 'inactive', default 'active')
- visits The number of times an affiliate's link has been visited (optional)
- sales The number of sales completed after following the affiliates link (optional)
Return values
int —The ID of the affiliate that was created, void on error
affiliateMonthlyReport()
Send a affiliate email report for the previous month.
public
affiliateMonthlyReport() : mixed
delete()
Permanently deletes the given affiliate
public
delete(int $affiliate_id[, bool $permanent = false ]) : mixed
Parameters
- $affiliate_id : int
-
The ID of the affiliate to delete
- $permanent : bool = false
-
True to permanently delete the affiliate and associated records, false to mark as inactive
edit()
Edit an affiliate
public
edit(int $affiliate_id, array<string|int, mixed> $vars) : int
Parameters
- $affiliate_id : int
-
The ID of the affiliate to edit
- $vars : array<string|int, mixed>
-
An array of input data including:
- client_id The ID of the client to associate the affiliate with
- code The code to use when creating referral links for this affiliate
- status The status of the affiliate ('active' or 'inactive', default 'active')
- visits The number of times an affiliate's link has been visited (optional)
- sales The number of sales completed after following the affiliates link (optional)
Return values
int —The ID of the affiliate that was updated, void on error
get()
Fetches the affiliate with the given ID
public
get(int $affiliate_id) : mixed
Parameters
- $affiliate_id : int
-
The ID of the affiliate to fetch
Return values
mixed —A stdClass object representing the affiliate, false if no such affiliate exists
getAffiliateDaysActive()
Get the number of days an affiliate has been active
public
getAffiliateDaysActive(int $affiliate_id) : int
Parameters
- $affiliate_id : int
-
The ID of the affiliate
Return values
int —The number of days the affiliate has been active
getAll()
Returns all affiliates in the system for the given company
public
getAll(int $company_id[, string $status = null ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch affiliates for
- $status : string = null
-
The status of the affiliates to fetch:
- "active" Only active affiliates
- "inactive" Only inactive affiliates
- null All affiliates
- $order : array<string|int, mixed> = ['id' => 'desc']
-
A key/value pair array of fields to order the results by
Return values
array<string|int, mixed> —An array of stdClass objects, each representing an affiliate
getByClientId()
Fetches the affiliate with the given client ID
public
getByClientId(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID of the client for which to fetch an affiliate
Return values
mixed —A stdClass object representing the affiliate, false if no such affiliate exists
getByCode()
Fetches the affiliate with the given code
public
getByCode(string $code) : mixed
Parameters
- $code : string
-
The affiliate code
Return values
mixed —A stdClass object representing the affiliate, false if no such affiliate exists
getList()
Returns a list of affiliates for the given company
public
getList(int $company_id[, string $status = null ][, int $page = 1 ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch affiliates from
- $status : string = null
-
The status of the affiliates to fetch:
- "active" Only active affiliates
- "inactive" Only inactive affiliates
- null All affiliates
- $page : int = 1
-
The page number of results to fetch
- $order : array<string|int, mixed> = ['id' => 'desc']
-
A key/value pair array of fields to order the results by
Return values
array<string|int, mixed> —An array of stdClass objects, each representing an affiliate
getListCount()
Returns the total number of affiliate for the given company
public
getListCount(int $company_id[, string $status = null ]) : int
Parameters
- $company_id : int
-
The ID of the company to fetch affiliate count from
- $status : string = null
-
The status of the affiliates to fetch:
- "active" Only active affiliates
- "inactive" Only inactive affiliates
- null All affiliates
Return values
int —The total number of affiliates for the given company
getStatusCount()
Retrieves the number of affiliates given an affiliate status
public
getStatusCount([string $status = 'active' ][, int $company_id = null ]) : int
Parameters
- $status : string = 'active'
-
The affiliate status type (optional, default 'active')
- $company_id : int = null
-
The ID of the company to count affiliates for (optional)
Return values
int —The number of affiliates of type $status
getStatuses()
Returns all supported affiliate statuses in key/value pairs
public
getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of affiliate statuses
getAffiliate()
Returns a partial affiliate query
private
getAffiliate([array<string|int, mixed> $filters = [] ]) : Record
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- status The affiliate status
- company_id The ID of the company to which the affiliate clients must be assigned
- client_id The ID of the client to which this affiliate is assigned
- code The code to which this affiliate is assigned
Return values
Record —A partially built affiliate query
getRules()
Returns all validation rules for adding/editing affiliates
private
getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
An array of input key/value pairs
- $edit : bool = false
-
True if this if an edit, false otherwise
Return values
array<string|int, mixed> —An array of validation rules