Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

_get_product_id_from_woocommerce_order

// WP_Query arguments
$args = array(
	'post_type'              => array( 'shop_order' ),
	'post_status'            => array( 'wc-processing' ),
	'meta_query'             => array(
		array(
			'key'     => '_product_id',
		),
	),
);

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