Support » Plugin: WooCommerce » How to hide content if product is not visible?

  • Resolved Drinkguesser

    (@drinkguesser)



    In older versions of WooCommerce I was able to use:

    <?php $visibility = get_post_meta($post->ID, '_visibility', true); if ($visibility == visible) { ?>
    
        Content displayed if product is visible
    
    <?php } else {   ?><!-- else if product is not visible -->
    
        Content displayed if product is not visible
    
    <?php } ?>

    But now it should be something else since this is no longer working with new products (https://createandcode.com/fix-broken-featured-products-woocommerce-3-0/), and uses taxonomy terms (and tax_query) instead of custom fields.

    What type of conditional statement would I use to achieve the same effect that I used to use?

Viewing 1 replies (of 1 total)
  • I received some help and here’s the solution:

    <?php $visibility = $product->is_visible(); if ( $visibility ) { ?>
    
        Content displayed if product is visible
    
    <?php } else {   ?><!-- else if product is not visible -->
    
        Content displayed if product is not visible
    
    <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘How to hide content if product is not visible?’ is closed to new replies.