Abstract_WC_Order_Data_Store_CPT::order_exists()publicWC 8.0.0

Check if an order exists by id.

Method of the class: Abstract_WC_Order_Data_Store_CPT{}

No Hooks.

Return

true|false. True if an order exists with the given name.

Usage

$Abstract_WC_Order_Data_Store_CPT = new Abstract_WC_Order_Data_Store_CPT();
$Abstract_WC_Order_Data_Store_CPT->order_exists( $order_id ): bool;
$order_id(int) (required)
The order id to check.

Changelog

Since 8.0.0 Introduced.

Abstract_WC_Order_Data_Store_CPT::order_exists() code WC 9.4.2

public function order_exists( $order_id ): bool {
	if ( ! $order_id ) {
		return false;
	}

	$post_object = get_post( $order_id );
	return ! is_null( $post_object ) && in_array( $post_object->post_type, wc_get_order_types(), true );
}