Admin Order Functions
Order Function Index |
Order Config |
Get Order Helper Data |
Save Order Data
Help with Admin Functions
Show / Hide Help
Name: The name of the function (method).
Data Type: The data type that is expected by the function.
- bool : Requires a boolean value of 'TRUE' or 'FALSE'.
- string : Requires a textual value.
- int : Requires a numeric value. It does not matter whether the value is an integer, float, decimal etc.
- array : Requires an array.
Required: Defines whether the parameter requires a value to be submitted.
Default: Defines the default parameter value that is used if no other value is submitted.
get_refund_itemised()
Gets an itemised query of refund totals for all items that have been cancelled within an order.
Library and Requirements
Available via the admin library only.
Requires all order database tables, and the 'shipped' and 'cancelled' order detail columns to be enabled.
Function Parameters
get_refund_itemised(order_number)
Help
Name |
Data Type |
Required |
Default |
Description |
order_number |
string | int |
Yes |
FALSE |
Defines the unique order number of the order to calculate the refund data for. |
How it Works
The function checks which order detail columns are enabled via the config file, and then runs an SQL query multiplying each quantity and currency total against the number of items that have been set as 'cancelled'.
The order detail columns that are queried are 'item_price', 'item_discount_price', 'item_tax', 'item_shipping_rate', 'item_weight' and 'item_reward_points'.
The function returns an itemised query of the refund totals for each item row.
Notes
Note: This function is only intended to be used as an accurate ESTIMATE of the value that should be refunded.
The returned value does not include any percentage based surcharge or discount values that may have been applied to the orders summary values.
A true representation of the orders new value can be achieved by reloading the 'to-be-refunded' order from the 'db_cart_data' table data, and resaving the order.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$order_number = 'example_order_number';
$this->flexi_cart_admin->get_refund_itemised($order_number)->result();
get_refund_summary()
Gets a summary of refund totals for all items that have been cancelled within an order.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
get_refund_itemised(order_number)
Help
Name |
Data Type |
Required |
Default |
Description |
order_number |
string | int |
Yes |
FALSE |
Defines the unique order number of the order to calculate the refund data for. |
How it Works
The function checks which order detail columns are enabled via the config file, and then runs an SQL query multiplying each quantity and currency total against the number of items that have been set as 'cancelled'.
The order detail columns that are queried are 'item_price', 'item_discount_price', 'item_tax', 'item_shipping_rate', 'item_weight' and 'item_reward_points'.
The function returns a summarised query of the refund totals for the whole order using SQL's SUM() aggregate function.
Notes
Note: This function is only intended to be used as an accurate ESTIMATE of the value that should be refunded.
The returned value does not include any percentage based surcharge or discount values that may have been applied to the orders summary value.
A true representation of the orders new value can be achieved by reloading the 'to-be-refunded' order from the 'db_cart_data' table data, and resaving the order.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$order_number = 'example_order_number';
$this->flexi_cart_admin->get_refund_summary($order_number)->row();
search_orders()
Gets data from the order summary and order status table via a keyword based search query.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
search_orders(search_query, exact_match, sql_select, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
search_query |
string | array |
Yes |
FALSE |
Defines the search terms used to query the order summary table. |
exact_match |
bool |
No |
FALSE |
Define whether all keywords within the search query must be in the matched records.
Example: For a search query of "John Smith", an exact match would not return a record matching the name "John".
|
sql_select |
string | array |
No |
FALSE |
Define the database fields returned via an SQL SELECT statement.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to return.
Read the defining SQL documentation for further information.
|
How it Works
The function works in a similar way to the get_db_order_summary() function, with the exception that it allows the returned results to be additionally filtered via search terms.
The submitted search term is split into individual terms that are then each matched against specific table columns that have been defined via the setting 'search_order_cols' in the libraries config. file.
If the function has defined the query to only return exact matches, then the SQL function will only return records where every individual term is matched to each record.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
If a string or int value is submitted to the 'sql_where' parameter, the function will match the value against the order number column.
Example: If 'sql_where' is submitted as 'X0123Y', the SQL WHERE statement will be "WHERE 'order_number_column' = 'X0123Y'
".
Note that this is functionality is different from other functions that only perform this behaviour when an int value is submitted.
This does however mean that string based SQL WHERE statements can not be used with this function, an array must be used instead.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$search_query = 'John Smith';
$exact_match = false;
$sql_select = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->search_orders($search_query, $exact_match, $sql_select, $sql_where)->result();
get_db_order()
Gets records from the order summary and order detail table using a user defined SQL SELECT query.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
get_db_order(sql_select, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_select |
string | array |
No |
FALSE |
Define the database fields returned via an SQL SELECT statement.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to return.
Read the defining SQL documentation for further information.
|
How it Works
The function runs a joined SQL SELECT statement on the 'Order Summary', 'Order Details' and 'Order Status' tables.
The query can be customised by submitting 'sql_select' and 'sql_where' data to the functions parameters.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
If a string or int value is submitted to the 'sql_where' parameter, the function will match the value against the order number column.
Example: If 'sql_where' is submitted as 'X0123Y', the SQL WHERE statement will be "WHERE 'order_number_column' = 'X0123Y'
".
Note that this is functionality is different from other functions that only perform this behaviour when an int value is submitted.
This does however mean that string based SQL WHERE statements can not be used with this function, an array must be used instead.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$sql_select = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->get_db_order($sql_select, $sql_where)->result();
get_db_order_summary()
Gets records from the order summary table using a user defined SQL SELECT query.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
get_db_order_summary(sql_select, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_select |
string | array |
No |
FALSE |
Define the database fields returned via an SQL SELECT statement.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to return.
Read the defining SQL documentation for further information.
|
How it Works
The function runs a joined SQL SELECT statement on the 'Order Summary' and 'Order Status' tables.
The query can be customised by submitting 'sql_select' and 'sql_where' data to the functions parameters.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
If a string or int value is submitted to the 'sql_where' parameter, the function will match the value against the order number column.
Example: If 'sql_where' is submitted as 'X0123Y', the SQL WHERE statement will be "WHERE 'order_number_column' = 'X0123Y'
".
Note that this is functionality is different from other functions that only perform this behaviour when an int value is submitted.
This does however mean that string based SQL WHERE statements can not be used with this function, an array must be used instead.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$sql_select = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->get_db_order_summary($sql_select, $sql_where)->result();
get_db_order_detail()
Gets records from the order detail table using a user defined SQL SELECT query.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
get_db_order_detail(sql_select, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_select |
string | array |
No |
FALSE |
Define the database fields returned via an SQL SELECT statement.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to return.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL SELECT statement on the ''Order Details' table.
By default, the SQL statement is NOT joined to any other order table, but can be by using flexi carts 'Query Builder - SQL JOIN' function. Alternatively use the 'get_db_order()' function.
The query can be customised by submitting 'sql_select' and 'sql_where' data to the functions parameters.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
If an int value is submitted to the 'sql_where' parameter, the function will automatically match the value against the tables primary key.
Example: If 'sql_where' is submitted as an int of '101', the SQL WHERE statement will be "WHERE 'primary_key_column' = 101
".
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$sql_select = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->get_db_order_detail($sql_select, $sql_where)->result();
update_db_order_summary()
Updates records in the order summary table using a user defined SQL WHERE and UPDATE statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
update_db_order_summary(sql_update, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_update |
array |
Yes |
FALSE |
Set the SQL UPDATE statement used to update data into the database.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to update.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL UPDATE statement on the 'Order Summary' table, updating data defined via the 'sql_update' parameter and filtered via the 'sql_where' parameter.
Notes
It is not recommended to use this function to update data regarding summary totals. The reason being that the data will not be able to be relate to the saved item totals in the order details table. However, updating other non-summary total data is fine to do.
If the status of an order is changed, the function will automatically manage the stock and discount allocation if defined to do so via the carts config settings. This means if an order is cancelled (Or uncancelled), the stock and discount usage limits will be reallocated accordingly.
This function is compatible with flexi carts 'Query Builder' functions.
If a string or int value is submitted to the 'sql_where' parameter, the function will match the value against the order number column.
Example: If 'sql_where' is submitted as 'X0123Y', the SQL WHERE statement will be "WHERE 'order_number_column' = 'X0123Y'
".
Note that this is functionality is different from other functions that only perform this behaviour when an int value is submitted.
This does however mean that string based SQL WHERE statements can not be used with this function, an array must be used instead.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | The number of affected rows.
Example
$sql_update = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->update_db_order_summary($sql_update, $sql_where);
update_db_order_details()
Updates records in the order detail table using a user defined SQL WHERE and UPDATE statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
update_db_order_details(sql_update, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_update |
array |
Yes |
FALSE |
Set the SQL UPDATE statement used to update data into the database.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to update.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL UPDATE statement on the 'Order Details' table, updating data defined via the 'sql_update' parameter and filtered via the 'sql_where' parameter.
Notes
It is not recommended to use this function to update data regarding item pricing or ordered item quantities. The reason being that the data will not be updated in the related order summary table.
However, it is recommended to use this function to update quantities from the 'item_quantity_shipped' and 'item_quantity_cancelled' columns as the function will automatically manage the stock allocation if defined to do so via the carts config settings.
Whereas the function manages stock allocation, it does not manage the usage limits of discounts and reward vouchers. Discount and reward voucher usage limits are only reallocated if the complete order status is cancelled via the 'update_db_order_summary()' function.
This function is compatible with flexi carts 'Query Builder' functions.
If an int value is submitted to the 'sql_where' parameter, the function will automatically match the value against the tables primary key.
Example: If 'sql_where' is submitted as an int of '101', the SQL WHERE statement will be "WHERE 'primary_key_column' = 101
".
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | The number of affected rows.
Example
$sql_update = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->update_db_order_details($sql_update, $sql_where);
delete_db_order()
Deletes records from the order summary and order detail table using a user defined SQL WHERE statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
delete_db_order(order_number)
Help
Name |
Data Type |
Required |
Default |
Description |
order_number |
string | int |
Yes |
FALSE |
Sets the SQL WHERE statement as the order number of the database record to delete. |
How it Works
The function runs an SQL DELETE statement on the 'Order Summary' table filtered via the 'order_number' parameter.
The function then deletes all related records from the 'Order Details' table.
Notes
Deleting an order will also delete any user reward points that are associated with it, as reward points are calculated from the order details table.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | The number of affected rows.
Example
$sql_where = array(...);
$this->flexi_cart_admin->delete_db_order($sql_where);
get_db_order_status()
Gets records from the order status table using a user defined SQL SELECT query.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
get_db_order_status(sql_select, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_select |
string | array |
No |
FALSE |
Define the database fields returned via an SQL SELECT statement.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to return.
Read the defining SQL documentation for further information.
|
How it Works
The function runs a SQL SELECT statement on the 'Order Status' table.
The query can be customised by submitting 'sql_select' and 'sql_where' data to the functions parameters.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
This function can be chained with CodeIgniters query functions 'result()', 'row()' etc.
Read the Query Result documentation for further information on all the combined flexi cart and CodeIgniter functions that are available.
If an int value is submitted to the 'sql_where' parameter, the function will automatically match the value against the tables primary key.
Example: If 'sql_where' is submitted as an int of '101', the SQL WHERE statement will be "WHERE 'primary_key_column' = 101
".
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:object
Example
$sql_select = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->get_db_order_status($sql_select, $sql_where)->result();
insert_db_order_status()
Inserts a new order status using a user defined SQL INSERT statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
insert_db_order_status(sql_insert)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_insert |
array |
Yes |
FALSE |
Set the SQL INSERT statement used to insert data into the database.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL INSERT statement on the 'Order Status' table, inserting data defined via the 'sql_insert' parameter.
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | id of the inserted record.
Example
$sql_insert = array(...);
$this->flexi_cart_admin->insert_db_order_status($sql_insert);
update_db_order_status()
Updates records in the order status table using a user defined SQL WHERE and UPDATE statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
update_db_order_status(sql_update, sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_update |
array |
Yes |
FALSE |
Set the SQL UPDATE statement used to update data into the database.
Read the defining SQL documentation for further information.
|
sql_where |
string | int | array |
No |
FALSE |
Set the SQL WHERE statement used to filter the database records to update.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL UPDATE statement on the 'Order Status' table, updating data defined via the 'sql_update' parameter and filtered via the 'sql_where' parameter.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
If an int value is submitted to the 'sql_where' parameter, the function will automatically match the value against the tables primary key.
Example: If 'sql_where' is submitted as an int of '101', the SQL WHERE statement will be "WHERE 'primary_key_column' = 101
".
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | The number of affected rows.
Example
$sql_update = array(...);
$sql_where = array(...);
$this->flexi_cart_admin->update_db_order_status($sql_update, $sql_where);
delete_db_order_status()
Deletes records from the order status table using a user defined SQL WHERE statement.
Library and Requirements
Available via the admin library only.
Requires all order database tables to be enabled.
Function Parameters
delete_db_order_status(sql_where)
Help
Name |
Data Type |
Required |
Default |
Description |
sql_where |
string | int | array |
Yes |
FALSE |
Set the SQL WHERE statement used to filter the database records to delete.
Read the defining SQL documentation for further information.
|
How it Works
The function runs an SQL DELETE statement on the 'Order Status' table filtered via the 'sql_where' parameter.
Notes
This function is compatible with flexi carts 'Query Builder' functions.
If an int value is submitted to the 'sql_where' parameter, the function will automatically match the value against the tables primary key.
Example: If 'sql_where' is submitted as an int of '101', the SQL WHERE statement will be "WHERE 'primary_key_column' = 101
".
Return Values
Failure:FALSE | An error message will be set if a required table/feature is disabled.
Success:int | The number of affected rows.
Example
$sql_where = array(...);
$this->flexi_cart_admin->delete_db_order_status($sql_where);