Automattic\WooCommerce\Internal\Utilities

COTMigrationUtil::is_order()publicWC 1.0

Checks if passed id, post or order object is a WC_Order object.

Method of the class: COTMigrationUtil{}

No Hooks.

Return

true|false. Whether the passed param is an order.

Usage

$COTMigrationUtil = new COTMigrationUtil();
$COTMigrationUtil->is_order( $order_id, $types ) : bool;
$order_id(int|WP_Post|WC_Order) (required)
Order ID, post object or order object.
$types(string[])
Types to match against.
Default: array( foo )

COTMigrationUtil::is_order() code WC 8.7.0

public function is_order( $order_id, array $types = array( 'shop_order' ) ) : bool {
	$order_id         = $this->get_post_or_order_id( $order_id );
	$order_data_store = \WC_Data_Store::load( 'order' );
	return in_array( $order_data_store->get_order_type( $order_id ), $types, true );
}