wc_get_order_types

Get all registered order types.

Description

(array) wc_get_order_types( (string) $for = '' ); 

$for optionally define what you are getting order types for so only relevant types are returned.

e.g. for order-meta-boxes,, order-count

Returns (array)

Parameters (1)

0. $for — Optional. (string) => ''
The for.

Usage

  1. if ( !function_exists( 'wc_get_order_types' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-order-functions.php'; 
  3.  
  4. // The for. 
  5. $for = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_order_types($for); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-order-functions.php  
  1. function wc_get_order_types( $for = '' ) { 
  2. global $wc_order_types; 
  3.  
  4. if ( ! is_array( $wc_order_types ) ) { 
  5. $wc_order_types = array(); 
  6.  
  7. $order_types = array(); 
  8.  
  9. switch ( $for ) { 
  10. case 'order-count' : 
  11. foreach ( $wc_order_types as $type => $args ) { 
  12. if ( ! $args['exclude_from_order_count'] ) { 
  13. $order_types[] = $type; 
  14. break; 
  15. case 'order-meta-boxes' : 
  16. foreach ( $wc_order_types as $type => $args ) { 
  17. if ( $args['add_order_meta_boxes'] ) { 
  18. $order_types[] = $type; 
  19. break; 
  20. case 'view-orders' : 
  21. foreach ( $wc_order_types as $type => $args ) { 
  22. if ( ! $args['exclude_from_order_views'] ) { 
  23. $order_types[] = $type; 
  24. break; 
  25. case 'reports' : 
  26. foreach ( $wc_order_types as $type => $args ) { 
  27. if ( ! $args['exclude_from_order_reports'] ) { 
  28. $order_types[] = $type; 
  29. break; 
  30. case 'sales-reports' : 
  31. foreach ( $wc_order_types as $type => $args ) { 
  32. if ( ! $args['exclude_from_order_sales_reports'] ) { 
  33. $order_types[] = $type; 
  34. break; 
  35. case 'order-webhooks' : 
  36. foreach ( $wc_order_types as $type => $args ) { 
  37. if ( ! $args['exclude_from_order_webhooks'] ) { 
  38. $order_types[] = $type; 
  39. break; 
  40. default : 
  41. $order_types = array_keys( $wc_order_types ); 
  42. break; 
  43.  
  44. return apply_filters( 'wc_order_types', $order_types, $for );