IF ( ! $loop->have_posts() ) condition doesn’t work – WP_Query

Products variations are a stored as a different post type, product_variation, so you have to add that post type to the query:

'post_type' => array( 'product', 'product_variation' )

Also, you could try to use WooCommerce specific functions, like wc_get_product_ids_on_sale(), wc_get_products() and so on, they could make your life easier when coding for WooCommerce.