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.

{} It's a method of the class: COTMigrationUtil{}

No Hooks.

Return

true|false|WC_Order|WC_Order_Refund. WC_Order object.

Usage

$COTMigrationUtil = new COTMigrationUtil();
$COTMigrationUtil->init_theorder_object( $post_or_order_object );
$post_or_order_object(WC_Order|WP_Post) (required)
Post or order object.

Code of COTMigrationUtil::init_theorder_object() WC 7.1.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;
}