OrderOrders extends OrderModel
Order Management
Table of Contents
Methods
| acceptPaidOrders() | If manual review is not required by the order form, marks all paid orders as accepted for all active clients for this company |
| add() | Add and invoice an order, by provisioning all services |
| cancel() | Cancels the given order |
| delete() | Deletes the given order |
| deleteHangingOrders() | Deletes any orders not associated with a valid invoice or service |
| eligibleFreeDomain() | Validates for the given service item if the ordered domain is eligible for free |
| get() | Fetch a specific order by order ID |
| getAbandoned() | Returns a list of all abandoned orders |
| getByNumber() | Fetch a specific order by order number |
| getList() | Fetches a list of all orders |
| getListCount() | Return the total number of orders returned from OrderOrders::getList(), useful in constructing pagination for the getList() method. |
| getOrdersByClientIdCount() | Return the total number of orders placed by an specific client |
| getPackagesFromItems() | Fetches all packages IDs ordered for the given pricing IDs |
| getSearchCount() | Returns the total number of orders returned from OrderOrders::search(), useful in constructing pagination |
| getStatuses() | Returns all possible order |
| notifyAbandonedOrders() | Sends a reminder for abandoned orders |
| search() | Search orders |
| sendAbandonedReminder() | Sends an abandoned order reminder notice for a given order |
| setStatus() | Sets the status for the given set of order ID values, updates client status appropriately (marking as fraud or active) |
| addService() | |
| getOrderNumber() | Generates a random order number |
| getOrders() | Fetches a partial Record object to fetch all orders of the given status for the current company |
| searchOrders() | Partially constructs the query for searching orders |
| sendAbandonedOrderReminders() | Send abandoned order notices for the given order form if configured |
Methods
acceptPaidOrders()
If manual review is not required by the order form, marks all paid orders as accepted for all active clients for this company
public
acceptPaidOrders() : mixed
Tags
add()
Add and invoice an order, by provisioning all services
public
add(array<string|int, mixed> $details, array<string|int, mixed> $items) : stdClass
Parameters
- $details : array<string|int, mixed>
-
An array of order details including:
- client_id The ID of the client to add the order for
- order_form_id The ID of the order form the order was placed under
- currency The currency code the order was placed under
- fraud_report Fraud details in text format, optional default null
- fraud_status Fraud status ('allow', 'review', 'reject'), optional default null
- status The status of the order ('pending', 'accepted', 'fraud') default 'pending'
- coupon The coupon code used for the order, optional default null
- ip_address The IP address of the customer that placed the order (optional, default null)
- $items : array<string|int, mixed>
-
A numerically indexed array of order items including:
- parent_service_id The ID of the service this service is a child of (optional)
- package_group_id The ID of the package group this service was added from (optional)
- pricing_id The package pricing schedule ID for this service
- module_row_id The module row to add the service under (optional, default module will decide)
- addons An array of addon items each including:
- package_group_id The ID of the package group this service was added from (optional)
- pricing_id The package pricing schedule ID for this service
- module_row_id The module row to add the service under (optional, default module will decide)
- qty The quantity consumed by this service (optional, default 1)
-
- Any other service field data to pass to the module
- qty The quantity consumed by this service (optional, default 1)
- transfer True if the service is being transferred, false otherwise (optional, default false)
-
- Any other service field data to pass to the module
Return values
stdClass —A stdClass object representing the order, void on error
cancel()
Cancels the given order
public
cancel(int $order_id) : mixed
Parameters
- $order_id : int
-
The ID of the order to delete
delete()
Deletes the given order
public
delete(int $order_id) : mixed
Parameters
- $order_id : int
-
The ID of the order to delete
deleteHangingOrders()
Deletes any orders not associated with a valid invoice or service
public
deleteHangingOrders() : mixed
eligibleFreeDomain()
Validates for the given service item if the ordered domain is eligible for free
public
eligibleFreeDomain(array<string|int, mixed> $service_item, array<string|int, mixed> $domain_item, stdClass $order_form) : bool
Parameters
- $service_item : array<string|int, mixed>
-
The array representing the service to validate against it
- $domain_item : array<string|int, mixed>
-
The array representing the domain to validate
- $order_form : stdClass
-
An object representing the order form
Return values
bool —True if the domain is eligible for free for the given service, false otherwise
get()
Fetch a specific order by order ID
public
get(int $order_id) : stdClass
Parameters
- $order_id : int
-
The ID of the order to fetch
Return values
stdClass —A stdClass object representing the order
getAbandoned()
Returns a list of all abandoned orders
public
getAbandoned(int $order_form_id[, int $elapsed_time = 24 ]) : array<string|int, mixed>
Parameters
- $order_form_id : int
-
The ID of the order form
- $elapsed_time : int = 24
-
The amount of time in hours that elapsed since the cart was abandoned
Return values
array<string|int, mixed> —A list of abandoned orders
getByNumber()
Fetch a specific order by order number
public
getByNumber(int $order_number) : stdClass
Parameters
- $order_number : int
-
The order number to fetch
Return values
stdClass —A stdClass object representing the order
getList()
Fetches a list of all orders
public
getList([string $status = null ][, int $page = 1 ][, string $order_by = ['order_number' => 'ASC'] ][, array<string|int, mixed> $filters = [] ]) : mixed
Parameters
- $status : string = null
-
The status of orders to fetch which can be one of, default null for all:
- pending
- accepted
- fraud
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order_by : string = ['order_number' => 'ASC']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
- $filters : array<string|int, mixed> = []
-
A list of order filters including: (optional)
- client_id The client ID on which to filter orders (optional)
Return values
mixed —An array of objects or false if no results.
getListCount()
Return the total number of orders returned from OrderOrders::getList(), useful in constructing pagination for the getList() method.
public
getListCount([string $status = null ][, array<string|int, mixed> $filters = [] ]) : int
Parameters
- $status : string = null
-
The status of orders to fetch which can be one of, default null for all:
- pending
- accepted
- fraud
- $filters : array<string|int, mixed> = []
-
A list of order filters including: (optional)
- client_id The client ID on which to filter orders (optional)
Tags
Return values
int —The total number of orders
getOrdersByClientIdCount()
Return the total number of orders placed by an specific client
public
getOrdersByClientIdCount(int $client_id) : int
Parameters
- $client_id : int
-
The ID of the client to fetch the placed orders
Return values
int —The total number of orders placed by the client
getPackagesFromItems()
Fetches all packages IDs ordered for the given pricing IDs
public
getPackagesFromItems(array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
- $items : array<string|int, mixed>
-
An array of items including:
- pricing_id The ID of the package pricing
Return values
array<string|int, mixed> —An array of package IDs derived from the given pricing_id values
getSearchCount()
Returns the total number of orders returned from OrderOrders::search(), useful in constructing pagination
public
getSearchCount(string $query) : mixed
Parameters
- $query : string
-
The value to search orders for
Tags
getStatuses()
Returns all possible order
public
getStatuses() : mixed
notifyAbandonedOrders()
Sends a reminder for abandoned orders
public
notifyAbandonedOrders() : mixed
search()
Search orders
public
search(string $query[, int $page = 1 ][, array<string|int, mixed> $order_by = ['date_added' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $query : string
-
The value to search orders for
- $page : int = 1
-
The page number of results to fetch (optional, default 1)
- $order_by : array<string|int, mixed> = ['date_added' => 'desc']
-
The sort=>$order options
Return values
array<string|int, mixed> —An array of tickets that match the search criteria
sendAbandonedReminder()
Sends an abandoned order reminder notice for a given order
public
sendAbandonedReminder(int $order_id, string $notice) : void
Parameters
- $order_id : int
-
The ID of the order for which to send the reminder
- $notice : string
-
Whether is the 'first', 'second' or 'third' notice
setStatus()
Sets the status for the given set of order ID values, updates client status appropriately (marking as fraud or active)
public
setStatus(array<string|int, mixed> $vars) : mixed
Parameters
- $vars : array<string|int, mixed>
-
An array of info containing:
- order_id An array of order ID values
- status The status to set for the order ID values:
- accepted
- pending
- fraud
- canceled
addService()
private
addService(array<string|int, mixed> $details, array<string|int, mixed> $item, array<string|int, mixed> $packages[, int $coupon_id = null ]) : int
Parameters
- $details : array<string|int, mixed>
-
An array of order details including:
- client_id The ID of the client to add the order for
- order_form_id The ID of the order form the order was placed under
- currency The currency code the order was placed under
- fraud_report Fraud details in text format, optional default null
- status The status of the order ('pending', 'accepted', 'fraud') default 'pending'
- coupon The coupon code used for the order, optional default null
- ip_address The IP address of the customer that placed the order (optional, default null)
- $item : array<string|int, mixed>
-
An array of item info including:
- parent_service_id The ID of the service this service is a child of (optional)
- package_group_id The ID of the package group this service was added from (optional)
- pricing_id The package pricing schedule ID for this service
- module_row_id The module row to add the service under (optional, default module will decide)
- addons An array of addon items each including:
- package_group_id The ID of the package group this service was added from (optional)
- pricing_id The package pricing schedule ID for this service
- module_row_id The module row to add the service under (optional, default module will decide)
- qty The quanity consumed by this service (optional, default 1)
-
- Any other service field data to pass to the module
- qty The quanity consumed by this service (optional, default 1)
-
- Any other service field data to pass to the module
- $packages : array<string|int, mixed>
-
A numerically indexed array of packages ordered along with this service to determine if the given coupon may be applied
- $coupon_id : int = null
-
The ID of the coupon used
Return values
int —The service ID of the service added, void on error
getOrderNumber()
Generates a random order number
private
getOrderNumber([string $prefix = null ]) : string
Parameters
- $prefix : string = null
-
A prefix to set for the order number
Return values
string —A random order number
getOrders()
Fetches a partial Record object to fetch all orders of the given status for the current company
private
getOrders([string $status = null ][, array<string|int, mixed> $filters = [] ]) : Record
Parameters
- $status : string = null
-
The status of orders to fetch which can be one of, default null for all:
- pending
- accepted
- fraud
- $filters : array<string|int, mixed> = []
-
A list of order filters including: (optional)
- client_id The client ID on which to filter orders (optional)
Return values
Record —The partially constructed query Record object
searchOrders()
Partially constructs the query for searching orders
private
searchOrders(string $query) : Record
Parameters
- $query : string
-
The value to search orders for
Tags
Return values
Record —The partially constructed query Record object
sendAbandonedOrderReminders()
Send abandoned order notices for the given order form if configured
private
sendAbandonedOrderReminders(stdClass $order_form) : mixed
Parameters
- $order_form : stdClass
-
The order form for which to send abandoned order notices