OrderAffiliateReferrals extends OrderModel
Order Affiliate Referral Management
Table of Contents
Methods
| add() | Add an affiliate referral |
| delete() | Permanently deletes the given affiliate referral |
| edit() | Edit an affiliate referral |
| get() | Fetches the affiliate referral with the given ID |
| getAll() | Returns all referrals in the system for the given affiliate |
| getList() | Returns a list of referrals for the given affiliate |
| getListCount() | Returns the total number of referrals for the given affiliate |
| getStatuses() | Returns all supported affiliate referral statuses in key/value pairs |
| matureAffiliateReferrals() | Evaluates whether any pending affiliate referrals have reached maturity. |
| getAffiliateReferral() | Returns a partial affiliate referral query |
| getRules() | Returns all validation rules for adding/editing affiliate referrals |
Methods
add()
Add an affiliate referral
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of input data including:
- affiliate_id The ID of the affiliate to which the referral belongs
- order_id The ID of the order with which the referral is associated
- name The name by which we can display and refer to the referral (optional)
- status The status of the referral (optional)
- amount The amount invoiced through this referral (optional)
- currency The currency this referral amount and commission is in (optional)
- commission The amount the affiliate can get payed out with this referral matures (optional)
Return values
int —The ID of the affiliate referral that was created, void on error
delete()
Permanently deletes the given affiliate referral
public
delete(int $referral_id) : mixed
Parameters
- $referral_id : int
-
The ID of the affiliate referral to delete
edit()
Edit an affiliate referral
public
edit(int $referral_id, array<string|int, mixed> $vars) : int
Parameters
- $referral_id : int
-
The ID of the affiliate referral to edit
- $vars : array<string|int, mixed>
-
An array of input data including:
- affiliate_id The ID of the affiliate to which the referral belongs
- order_id The ID of the order with which the referral is associated
- name The name by which we can display and refer to the referral (optional)
- status The status of the referral (optional)
- amount The amount invoiced through this referral (optional)
- currency The currency this referral amount and commission is in (optional)
- commission The amount the affiliate can get payed out with this referral matures (optional)
Return values
int —The ID of the referral that was updated, void on error
get()
Fetches the affiliate referral with the given ID
public
get(int $referral_id) : mixed
Parameters
- $referral_id : int
-
The ID of the referral to fetch
Return values
mixed —A stdClass object representing the referral, false if no such referral exists
getAll()
Returns all referrals in the system for the given affiliate
public
getAll([array<string|int, mixed> $filters = [] ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- affiliate_id The ID of the affiliate to fetch referrals from
- start_date Get the referrals from this start date
- end_date Get the referrals to this end date
- status The status of the referrals to fetch:
- "pending" Only pending referrals
- "mature" Only mature referrals
- "canceled" Only canceled referrals
- null All referrals
- $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 a referral
getList()
Returns a list of referrals for the given affiliate
public
getList([array<string|int, mixed> $filters = [] ][, int $page = 1 ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- affiliate_id The ID of the affiliate to fetch referrals from
- start_date Get the referrals from this start date
- end_date Get the referrals to this end date
- status The status of the referrals to fetch:
- "pending" Only pending referrals
- "mature" Only mature referrals
- "canceled" Only canceled referrals
- null All referrals
- $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 a referral
getListCount()
Returns the total number of referrals for the given affiliate
public
getListCount([array<string|int, mixed> $filters = [] ]) : int
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- affiliate_id The ID of the affiliate to fetch referral count from
- start_date Get the referrals from this start date
- end_date Get the referrals to this end date
- status The status of the referrals to fetch:
- "pending" Only pending referrals
- "mature" Only mature referrals
- "canceled" Only canceled referrals
- null All referrals
Return values
int —The total number of referrals for the given affiliate
getStatuses()
Returns all supported affiliate referral statuses in key/value pairs
public
getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of affiliate referral statuses
matureAffiliateReferrals()
Evaluates whether any pending affiliate referrals have reached maturity.
public
matureAffiliateReferrals() : mixed
getAffiliateReferral()
Returns a partial affiliate referral query
private
getAffiliateReferral([array<string|int, mixed> $filters = [] ]) : Record
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- affiliate_id The ID of the affiliate to fetch referrals from
- start_date Get the referrals from this start date
- end_date Get the referrals to this end date
- status The status of the referrals to fetch:
- "pending" Only pending referrals
- "mature" Only mature referrals
- "canceled" Only canceled referrals
- null All referrals
Return values
Record —A partially built affiliate referral query
getRules()
Returns all validation rules for adding/editing affiliate referrals
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