wc_get_order_types()
Get all registered order types.
Хуки из функции
Возвращает
Массив.
Использование
wc_get_order_types( $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'.
По умолчанию:''
Список изменений
| С версии 2.2 | Введена. |
Код wc_get_order_types() wc get order types WC 10.5.0
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;
case 'cot-migration':
foreach ( $wc_order_types as $type => $args ) {
if ( DataSynchronizer::PLACEHOLDER_ORDER_POST_TYPE !== $type ) {
$order_types[] = $type;
}
}
break;
case 'admin-menu':
$order_types = array_intersect(
array_keys( $wc_order_types ),
get_post_types(
array(
'show_ui' => true,
'show_in_menu' => 'woocommerce',
)
)
);
break;
default:
$order_types = array_keys( $wc_order_types );
break;
}
return apply_filters( 'wc_order_types', $order_types, $for );
}