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{}

Хуков нет.

Возвращает

WC_Order. WC_Order object.

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

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

Код COTMigrationUtil::init_theorder_object() WC 6.9.4

public function init_theorder_object( $post_or_order_object ) : WC_Order {
	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;
}