• Resolved Jeff Sherk

    (@jsherk)


    **Describe the bug**
    Product still shows up in search results even when catalog visibility is to to “shop only” or “hidden”.

    **To Reproduce**
    Create a Simple Product that is Virual and is also Downloadable called My Dogs.
    Set the catalog visibility to hidden.
    Publish the product.
    Search your site with example.com/?s=dogs
    The product will still show up on search results page (but is successfully hidden from shop page).
    NOTE: Setting catalog visibility to “search results only” will succesfully hide it from the Shop as well.

    **Expected behavior**
    When catalog visibility is set to “shop only” or “hidden” the product should NOT show up in any search results.

    **Isolating the problem (mark completed items with an [x]):**
    – [x] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
    – [x] This bug happens with a default WordPress theme active, or [Storefront](https://woocommerce.com/storefront/).
    – [x] I can reproduce this bug consistently using the steps above.

    **WordPress Environment**
    WordPress v5.3.2 and WooCommerce v3.9.1

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @jsherk

    Products do not show up in search if they are hidden from the catalog.

    Typically issues like this are caused by a theme or plugin conflict. Try switching back to a default theme like Twenty Twenty and disabling all plugins except for WooCommerce to see if this resolves the issue. Here is a link that better outlines that process:

    https://docs.woocommerce.com/document/woocommerce-self-service-guide/#section-4

    If this fixes the issue, then re-enable each plugin one at a time, then the theme, until you find the one that’s causing the conflict.

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hello @jsherk

    We haven’t heard back and will resolve this ticket. Should you still have questions or problems, please create a new thread and we’ll be happy to help further.

    Thanks,

    Thread Starter Jeff Sherk

    (@jsherk)

    I have posted this bug on github:
    https://github.com/woocommerce/woocommerce/issues/25563

    There are others reporting the same issue.

    @johndcoy it is WooCommerce’s bug it happen on all themes.

    Hello! Is it solved?
    I’m also facing the same issue!
    I’ve enabled all the necessary options in WooCommerce-> Product Visibility by Country Options. But still, the product shows on search!!

    Hi, I had the same issue. ‘hidden’ products would be hidden from the product search but not from general site search. I added a product category called “hide-from-search” and added the following action hook to functions.php.

    This excludes any product in that category from the search results. You still need to hide the product to remove it from up-sell/cross-sell etc.

    function exclude_product_category_from_search ( $query ) {
        global $wp_the_query;
        if($query === $wp_the_query && $query->is_search() && !is_admin()) {
            $tax_query = array(
                array(
                    'taxonomy' => 'product_cat',
                    'field' => 'slug',
                    'terms' => 'hide-from-search',
                    'operator' => 'NOT IN',
                )
            );
            $query->set( 'tax_query', $tax_query );
        }
    }
    add_filter('pre_get_posts','exclude_product_category_from_search');

    This is adapted from this post: https://wordpress.stackexchange.com/questions/295096/hide-custom-post-type-from-search-based-on-custom-taxonomy

    Hope it helps.
    -C

    • This reply was modified 4 years, 9 months ago by colinfroggatt.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Products still show in search results even with Catalog Visibility set to Hidden’ is closed to new replies.