<?php
uc_order_state_list($scope = 'all', $sql = FALSE)
?>Order states are defined by modules implementing hook_order_state(). An order state is a definite step in the workflow of an order, like a stage in its life from creation to completion. States are designed to be dependable, so modules can be sure that certain states exist. The following states are defined in core Ubercart modules:
- uc_order.module - canceled, in_checkout, post_checkout, completed
- uc_payment.module - payment_received
Order statuses are all categorized according to an order state. Furthermore, order states have a scope. For now, these are either general or specific. The statuses belonging to states with a general scope are used in general order status lists and for denoting orders that should be counted in reports, customer listings, and order overview pages.
- $scope - Specify the scope for the order states you want listed - all, general, or specific. States with a general scope are used on general lists and pages.
- $sql - Pass this parameter as TRUE to alter the return value for a SQL query.
The return value will be either an array of state arrays (containing the keys id, title, weight, and scope) or a string containing an array of state ids for use in a SQL query.
<?php
// An example creating an options array for a select box.
foreach (uc_order_state_list() as $state) {
$options[$state['id']] = $state['title'];
}
$form['status_state'] = array(
'#type' => 'select',
'#title' => t('Order state'),
'#description' => t('Set which order state this status is for.'),
'#options' => $options,
'#default_value' => 'post_checkout',
);
// An example using this function in a query.
$result = db_query("SELECT * FROM {uc_order_statuses} WHERE state IN "
. uc_order_state_list('general', TRUE));
?>

