You are here

function commerce_order_statuses in Commerce Core 7

Returns an array of some or all of the order statuses keyed by name.

Parameters

$conditions: An array of conditions to filter the returned list by; for example, if you specify 'state' => 'cart' in the array, then only order statuses in the cart state would be included.

Return value

The array of order status objects, keyed by status name.

14 calls to commerce_order_statuses()
commerce_cart_order_id in modules/cart/commerce_cart.module
Returns the current cart order ID for the given user.
commerce_cart_order_is_cart in modules/cart/commerce_cart.module
Determines whether or not the given order is a shopping cart order.
commerce_cart_user_update in modules/cart/commerce_cart.module
Implements hook_user_update().
commerce_order_commerce_customer_profile_can_delete in modules/order/commerce_order.module
Implements hook_commerce_customer_profile_can_delete().
commerce_order_customer_order_view_access in modules/order/commerce_order_ui.module
Menu item access callback: prevent view access to the customer order display for orders in a 'cart' status and then perform a normal order access check.

... See full list

1 string reference to 'commerce_order_statuses'
commerce_order_statuses_reset in modules/order/commerce_order.module
Resets the cached list of order statuses.

File

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

Code

function commerce_order_statuses($conditions = array()) {

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

  // If it did not exist, fetch the statuses now.
  if (!isset($order_statuses)) {
    $order_statuses = module_invoke_all('commerce_order_status_info');

    // Merge in defaults.
    foreach ($order_statuses as $name => $order_status) {

      // Set some defaults for the checkout pane.
      $defaults = array(
        'cart' => FALSE,
        'weight' => 0,
        'status' => TRUE,
      );
      $order_status += $defaults;
      $order_statuses[$name] = $order_status;
    }

    // Give other modules a chance to alter the order statuses.
    drupal_alter('commerce_order_status_info', $order_statuses);
    uasort($order_statuses, 'drupal_sort_weight');
  }

  // Apply conditions to the returned statuses if specified.
  if (!empty($conditions)) {
    $matching_statuses = array();
    foreach ($order_statuses as $name => $order_status) {

      // Check the status against the conditions array to determine whether to
      // add it to the return array or not.
      $valid = TRUE;
      foreach ($conditions as $property => $value) {

        // If the current value for the specified property on the status does
        // not match the filter value...
        if ($order_status[$property] != $value) {

          // Do not add it to the temporary array.
          $valid = FALSE;
        }
      }
      if ($valid) {
        $matching_statuses[$name] = $order_status;
      }
    }
    return $matching_statuses;
  }
  return $order_statuses;
}