uc_order_status_list

Function uc_order_status_list() in uc_order.module:
<?php
 
function uc_order_status_list($scope = 'all', $sql = FALSE, $action = '')
?>

Description:

Order statuses are stored in the database and may be created either by modules or through the settings form by administrators with the proper access. Statuses may be renamed and reordered, and those created by administrators may be removed. Modules that need to pull up a list of order statuses with their current settings should use this function.

Every order status corresponds to an order state. Ubercart depends on knowing certain order statuses exist and are parts of certain order states. The following statuses are created by core modules:

  • uc_order.module - canceled, in_checkout, pending, processing, completed
  • uc_payment.module - payment_received

Because order statuses all correspond to an order state, you may load a list of order statuses based on order state or even a particular scope of order states using the $scope argument.

Order statuses defined by modules may be locked so they are never deleted. Locked order statuses may not be reassigned to different order states.

Parameters:
  • $scope - Defaults to all, but you may specify the scope for the order statuses you want listed based on their corresponding order state. Possible values are - all, general, specific, or any order state id.
  • $sql - Pass this parameter as TRUE to alter the return value for a SQL query.
  • $action - By default, this is empty. Since order statuses are cached, you can pass in 'rebuild' to reload the contents from the database if you are making changes to statuses on a page load.
Return value:

The return value will be either an array of status arrays (containing the keys id, title, state, and weight) or a string containing an array of status ids for use in a SQL query.


Example:
<?php
 
// Retrieve and list all defined order statuses.
 
foreach (uc_order_status_list() as $status) {
   
$statuses[] = $status['title'];
  }
 
$output = t('The following order statuses have been defined:')
            .
theme('item_list', $statuses);

 

// An example using this function in a query.  Selects all orders that
  // have a status in the post_checkout state.
 
$result = db_query("SELECT * FROM {uc_orders} WHERE order_status IN "
                  
. uc_order_status_list('post_checkout', TRUE));
?>