Automattic\WooCommerce\Internal\Utilities

COTMigrationUtil::init_theorder_object()publicWC 1.0

Helper function to initialize the global $theorder object, mostly used during order meta boxes rendering.

Метод класса: COTMigrationUtil{}

Хуков нет.

Возвращает

true|false|WC_Order|WC_Order_Refund. WC_Order object.

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

$COTMigrationUtil = new COTMigrationUtil();
$COTMigrationUtil->init_theorder_object( $post_or_order_object );
$post_or_order_object(WC_Order|WP_Post) (обязательный)
Post or order object.

Код COTMigrationUtil::init_theorder_object() WC 8.7.0

public function init_theorder_object( $post_or_order_object ) {
	global $theorder;
	if ( $theorder instanceof WC_Order ) {
		return $theorder;
	}

	if ( $post_or_order_object instanceof WC_Order ) {
		$theorder = $post_or_order_object;
	} else {
		$theorder = wc_get_order( $post_or_order_object->ID );
	}
	return $theorder;
}