• Resolved ilyapokrov

    (@ilyapokrov)


    For some products, I use a function to change the catalog visibility to hidden.
    Example: $ product-> set_catalog_visibility (‘hidden’);
    Now, for all such products, I need to display specific text in the main product description.
    But I cannot find the difference in these products as no extra class is added for hidden products.

    How can I write a function that will be marked to apply the function only when the product visibility is “Hidden”?

    Example:

    function woocommerce_hidden () {
        echo '<div class = "woocommerce_hidden"> text </div>';
    }
    add_action ('woocommerce_before_add_to_cart_form', 'woocommerce_hidden', 5);
    • This topic was modified 4 years, 2 months ago by ilyapokrov.
    • This topic was modified 4 years, 2 months ago by ilyapokrov.
Viewing 1 replies (of 1 total)
  • Hello @ilyapokrov,

    Great question. When the products are hidden from the catalog, they are actually removed from the page’s generated code. They aren’t hidden via CSS. It’s like they were never there. So we can’t bring them back with some CSS.

    You would need to alter the query directly to change how hidden products are handled. This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the following places for more development-oriented questions:

Viewing 1 replies (of 1 total)
  • The topic ‘How to apply CSS for products with hidden catalog visibility?’ is closed to new replies.