plugin development – WooCommerce maintaince mode by using php

I would like to open up certain parts of my website where the remaining pages should only be accessible as an administrator on the website.

I have made a maintaince plugin and it all works as it should. However, I have trouble filtering users by which page they are visiting.

I would like to open up a specific product category, as well as all products that belong to this category.

If I am not logged in as an administrator, I can not access the product category and products belonging to it.

My code is below – anyone can see what I’m doing wrong?

Thanks.

<?php

@return void

function ng_maintenance_mode() {
    global $pagenow;

    if ( ! current_user_can('administrator') ) {

        if ( $pagenow !== 'wp-login.php' && ! is_product_category( 232 ) && ! has_term( 232, 'product_cat' ) {

                    header( $_SERVER("SERVER_PROTOCOL") . ' 503 Service Temporarily Unavailable', true, 503 );
                    header( 'Content-Type: text/html; charset=utf-8' );
                    if ( file_exists( plugin_dir_path( __FILE__ ) . 'views/maintenance.php' ) ) {
                        require_once( plugin_dir_path( __FILE__ ) . 'views/maintenance.php' );
                    }
                    die();

                }

        }

}

add_action( 'wp_loaded', 'ng_maintenance_mode' );

?>