wc_get_order_types( string $for = '' )
Get all registered order types.
Description Description
Parameters Parameters
- $for
-
(Optional) y define what you are getting order types for so only relevant types are returned. e.g. for 'order-meta-boxes', 'order-count'.
Default value: ''
Return Return
(array)
Source Source
File: includes/wc-order-functions.php
function wc_get_order_types( $for = '' ) {
global $wc_order_types;
if ( ! is_array( $wc_order_types ) ) {
$wc_order_types = array();
}
$order_types = array();
switch ( $for ) {
case 'order-count':
foreach ( $wc_order_types as $type => $args ) {
if ( ! $args['exclude_from_order_count'] ) {
$order_types[] = $type;
}
}
break;
case 'order-meta-boxes':
foreach ( $wc_order_types as $type => $args ) {
if ( $args['add_order_meta_boxes'] ) {
$order_types[] = $type;
}
}
break;
case 'view-orders':
foreach ( $wc_order_types as $type => $args ) {
if ( ! $args['exclude_from_order_views'] ) {
$order_types[] = $type;
}
}
break;
case 'reports':
foreach ( $wc_order_types as $type => $args ) {
if ( ! $args['exclude_from_order_reports'] ) {
$order_types[] = $type;
}
}
break;
case 'sales-reports':
foreach ( $wc_order_types as $type => $args ) {
if ( ! $args['exclude_from_order_sales_reports'] ) {
$order_types[] = $type;
}
}
break;
case 'order-webhooks':
foreach ( $wc_order_types as $type => $args ) {
if ( ! $args['exclude_from_order_webhooks'] ) {
$order_types[] = $type;
}
}
break;
default:
$order_types = array_keys( $wc_order_types );
break;
}
return apply_filters( 'wc_order_types', $order_types, $for );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.2 | Introduced. |