You are here

function hook_commerce_order_state_info in Commerce Core 7

Defines order states for use in grouping order statuses together.

An order state is a particular phase in the life-cycle of an order that is comprised of one or more order statuses. In that regard, an order state is little more than a container for order statuses with a default status per state. This is useful for categorizing orders and advancing orders from one state to the next without needing to know the particular status an order will end up in.

The Order module defines several order states in its own implementation of this hook, commerce_order_commerce_order_state_info():

  • Canceled: for orders that have been canceled through some user action
  • Pending: for orders that have been created and are awaiting further action
  • Completed: for orders that have been completed as far as the customer should be concerned.

Additionally, the Cart and Checkout modules define the following order states:

  • Shopping cart: for orders that have not been completed by the customer yet
  • Checkout: for orders that have begun but not completed the checkout process

The order state array structure is as follows:

  • name: machine-name identifying the order state using lowercase alphanumeric characters, -, and _
  • title: the translatable title of the order state, used in administrative interfaces
  • description: a translatable description of the types of orders that would be in this state
  • weight: integer weight of the state used for sorting lists of order states; defaults to 0
  • default_status: name of the default order status for this state

Return value

An array of order state arrays keyed by name.

3 functions implement hook_commerce_order_state_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

commerce_cart_commerce_order_state_info in modules/cart/commerce_cart.module
Implements hook_commerce_order_state_info().
commerce_checkout_commerce_order_state_info in modules/checkout/commerce_checkout.module
Implements hook_commerce_order_state_info().
commerce_order_commerce_order_state_info in modules/order/commerce_order.module
Implements hook_commerce_order_state_info().
1 invocation of hook_commerce_order_state_info()
commerce_order_states in modules/order/commerce_order.module
Returns an array of all the order states keyed by name.

File

modules/order/commerce_order.api.php, line 44
Hooks provided by the Order module.

Code

function hook_commerce_order_state_info() {
  $order_states = array();
  $order_states['completed'] = array(
    'name' => 'completed',
    'title' => t('Completed'),
    'description' => t('Orders in this state have been completed as far as the customer is concerned.'),
    'weight' => 10,
    'default_status' => 'completed',
  );
  return $order_states;
}