You are here

function commerce_order_states in Commerce Core 7

Returns an array of all the order states keyed by name.

Order states can only be defined by modules but may have settings overridden that are stored in the database (weight and the default status). When this function is first called, it will load all the states as defined by hook_commerce_order_state_info() and update them based on the data in the database. The final array will be cached for subsequent calls.

2 calls to commerce_order_states()
commerce_order_state_get_title in modules/order/commerce_order.module
Returns the human readable title of any or all order states.
commerce_order_state_load in modules/order/commerce_order.module
Returns an order state object.
1 string reference to 'commerce_order_states'
commerce_order_states_reset in modules/order/commerce_order.module
Resets the cached list of order states.

File

modules/order/commerce_order.module, line 1006
Defines the core Commerce order entity and API functions to manage orders and interact with them.

Code

function commerce_order_states() {

  // First check the static cache for an order states array.
  $order_states =& drupal_static(__FUNCTION__);

  // If it did not exist, fetch the statuses now.
  if (empty($order_states)) {
    $order_states = module_invoke_all('commerce_order_state_info');

    // Give other modules a chance to alter the order states.
    drupal_alter('commerce_order_state_info', $order_states);
    uasort($order_states, 'drupal_sort_weight');
  }
  return $order_states;
}