Automattic\WooCommerce\Internal\Utilities

COTMigrationUtil::get_post_or_order_id()publicWC 1.0

Helper function to id from an post or order object.

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

Хуков нет.

Возвращает

int. Order or post ID.

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

$COTMigrationUtil = new COTMigrationUtil();
$COTMigrationUtil->get_post_or_order_id( $post_or_order_object ) : int;
$post_or_order_object(WP_Post/WC_Order) (обязательный)
WP_Post/WC_Order object to get ID for.

Код COTMigrationUtil::get_post_or_order_id() WC 6.9.4

public function get_post_or_order_id( $post_or_order_object ) : int {
	if ( is_int( $post_or_order_object ) ) {
		return $post_or_order_object;
	} elseif ( $post_or_order_object instanceof WC_Order ) {
		return $post_or_order_object->get_id();
	} elseif ( $post_or_order_object instanceof WP_Post ) {
		return $post_or_order_object->ID;
	}
	return 0;
}