WC_Order_Factory::get_class_name_for_order_id()private staticWC 6.9.0

Gets the class name an order instance should have based on its ID.

{} Это метод класса: WC_Order_Factory{}

Хуки из метода

Возвращает

Строку. The class name or FALSE if the class does not exist.

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

$result = WC_Order_Factory::get_class_name_for_order_id( $order_id );
$order_id(int) (обязательный)
The order ID.

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

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

Код WC_Order_Factory::get_class_name_for_order_id() WC 6.9.4

private static function get_class_name_for_order_id( $order_id ) {
	$order_type      = WC_Data_Store::load( 'order' )->get_order_type( $order_id );
	$order_type_data = wc_get_order_type( $order_type );
	if ( $order_type_data ) {
		$classname = $order_type_data['class_name'];
	} else {
		$classname = false;
	}

	/**
	 * Filter classname so that the class can be overridden if extended.
	 *
	 * @param $classname  Order classname.
	 * @param $order_type Order type.
	 * @param $order_id   Order ID.
	 */
	$classname = apply_filters( 'woocommerce_order_class', $classname, $order_type, $order_id );

	if ( ! class_exists( $classname ) ) {
		return false;
	}

	return $classname;
}