Support » Plugin: Advanced Woo Search » Product Visibility compatibility

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Please try to use following snippet

    add_filter( 'aws_search_results_products', 'aws_search_results_products' );
    
    function aws_search_results_products( $products_array ) {
    
        $new_products_array = array();
    
        foreach( $products_array as $product_array ) {
    
            $post_id = $product_array['post_data']->ID;
    
            if ( function_exists( 'alg_wc_pvbur_get_current_user_all_roles' ) && function_exists( 'alg_wc_pvbur_get_invisible_products_ids' ) ) {
                $post__not_in          = array();
                $current_user_roles    = alg_wc_pvbur_get_current_user_all_roles();
                $invisible_product_ids = alg_wc_pvbur_get_invisible_products_ids( $current_user_roles,true );
    
                if ( is_array( $invisible_product_ids ) && count( $invisible_product_ids ) > 0 ) {
                    foreach ( $invisible_product_ids as $invisible_product_id ) {
                        $filter = apply_filters( 'alg_wc_pvbur_is_visible', false, $current_user_roles, $invisible_product_id );
                        if ( ! filter_var( $filter, FILTER_VALIDATE_BOOLEAN ) ) {
                            $post__not_in[] = $invisible_product_id;
                        }
                    }
                }
    
                $post__not_in = array_unique( $post__not_in );
    
                if ( in_array( $post_id, $post__not_in ) ) {
                    continue;
                }
    
            }
    
            $new_products_array[] = $product_array;
    
        }
    
        return $new_products_array;
    
    } 

    Also after adding it go to plugin settings page and click ‘Clear cache’ button.

    Thanks Illid,
    That seems to be working for products that are hidden individually (from their individual product page) but not for products added to the bulk area of the visibility plugin. This looks to be more an issue with the Product Visibility by User Role plugin than it is an issue with your fix.

    Thanks for the snippet — looks to be working as expected!

    Illid,
    Just to follow up, I can confirm that setting the products to hidden individually works with your fix, but setting products to hidden in the bulk section of the PRO version of the plugin does not seem compatible with your fix. Any solution for that element?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product Visibility compatibility’ is closed to new replies.