WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wc_register_order_type() WC 2.2

Register order type. Do not use before init.

Wrapper for register post type, as well as a method of telling WC which. post types are types of orders, and having them treated as such.

$args are passed to register_post_type, but there are a few specific to this function:

  • exclude_from_orders_screen (bool) Whether or not this order type also get shown in the main. orders screen.
  • add_order_meta_boxes (bool) Whether or not the order type gets shop_order meta boxes.
  • exclude_from_order_count (bool) Whether or not this order type is excluded from counts.
  • exclude_from_order_views (bool) Whether or not this order type is visible by customers when. viewing orders e.g. on the my account page.
  • exclude_from_order_reports (bool) Whether or not to exclude this type from core reports.
  • exclude_from_order_sales_reports (bool) Whether or not to exclude this type from core sales reports.

Хуков нет.

Возвращает

true/false. Success or failure

Использование

wc_register_order_type( $type, $args );
$type(строка) (обязательный)
Post type. (max. 20 characters, can not contain capital letters or spaces).
$args(массив)
An array of arguments.
По умолчанию: array()

Заметки

  • Смотрите: register_post_type for $args used in that function

Список изменений

С версии 2.2 Введена.

Код wc register order type: woocommerce/includes/wc-order-functions.php WC 4.3.2

<?php
function wc_register_order_type( $type, $args = array() ) {
	if ( post_type_exists( $type ) ) {
		return false;
	}

	global $wc_order_types;

	if ( ! is_array( $wc_order_types ) ) {
		$wc_order_types = array();
	}

	// Register as a post type.
	if ( is_wp_error( register_post_type( $type, $args ) ) ) {
		return false;
	}

	// Register for WC usage.
	$order_type_args = array(
		'exclude_from_orders_screen'       => false,
		'add_order_meta_boxes'             => true,
		'exclude_from_order_count'         => false,
		'exclude_from_order_views'         => false,
		'exclude_from_order_webhooks'      => false,
		'exclude_from_order_reports'       => false,
		'exclude_from_order_sales_reports' => false,
		'class_name'                       => 'WC_Order',
	);

	$args                    = array_intersect_key( $args, $order_type_args );
	$args                    = wp_parse_args( $args, $order_type_args );
	$wc_order_types[ $type ] = $args;

	return true;
}