Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

unpaid_orders_query

gets a list of unpaid Woocommerce orders

// WP_Query arguments
$args = array(
	'post_type'              => array( 'shop_order' ),
	'post_status'            => array( 'wc-pending' ),
	'posts_per_page'         => '5',
	'date_query'             => array(
		array(
			'before'        => '-24 hours',
		),
	),
	'meta_query'             => array(
		'relation' => 'OR',
		array(
			'key'     => '_send_unpaid_order_notification',
			'value'   => 'yes',
			'compare' => '!=',
		),
		array(
			'key'     => '_send_unpaid_order_notification',
			'compare' => 'NOT EXISTS',
		),
	),
);

// The Query
$query = new WP_Query( $args );