Turn off visibility for WooCommerce Hidden products within sort list

Catalog visibility for WooCommerce is a simple way to keep certain products visible or invisible for customers, hidden products will not show on front side shop. Mainly this is being used for content not yet available or under development. The option is being integrated within Publish widget or through Quick Edit.

The Advanced Post Types Order is an easy tool to control the WooCommece Products Order this can be achieved through sort lists. When the shop contain too many hidden products, the re-order process can become disorganized. An easy approach will be to add a meta data information within the re-order interface, right to each product title. This can be done using a filter described at Additional information’s for object sort row

As alternative, they can be removed from the list using another filter apto/interface_query_args The following code demonstrate how to achieve that:

    add_filter('apto/interface_query_args', 'apto_interface_query_args', 99, 2);
    function  apto_interface_query_args($args, $current_sort_view_ID)
        {
            
            global $APTO;
            
            //check if WooCommerce sort
            if  ( $APTO->functions->is_woocommerce ( $args['sort_id'] ) === FALSE )
                return $args;
                
            $additional_query   =   array(
                                            'taxonomy' =>   'product_visibility',
                                            'field'    =>   'slug',
                                            'terms'    =>   array('exclude-from-search', 'exclude-from-catalog'),
                                            'operator' =>   'NOT IN',
                                );
   
            if  ( isset($args['tax_query']) )
                $args['tax_query'][]    =   $additional_query;
                else
                $args['tax_query']  =   array ( $additional_query ) ;
                
            return $args;   
        }