100, 'products' => 100, ); foreach ( $thresholds as $key => $threshold ) { try { switch ( $key ) { case 'orders': $orders_query = new \WC_Order_Query( array( 'status' => 'any', 'limit' => 1, 'paginate' => true, 'return' => 'ids', ) ); $orders_results = $orders_query->get_orders(); if ( $orders_results->total >= $threshold ) { $check = true; } break; case 'products': $products_query = new \WC_Product_Query( array( 'status' => 'any', 'limit' => 1, 'paginate' => true, 'return' => 'ids', ) ); $products_results = $products_query->get_products(); if ( $products_results->total >= $threshold ) { $check = true; } break; } } catch ( \Exception $exception ) { break; } if ( ! is_null( $check ) ) { break; } } return $check; } }