• Hi, I’ve already checked the “Hide out of stock items from catalog” option in Woocommerce>>>Inventory.
    It works great. But when I change my product inventory, it will automatically hide the out of stock variation. For example, there are three variations S | M | L in a product, and the variation M is set to out-of-stock. I want it shows S | M | L with graying out M, but it just shows S | L.
    I have this code in functions.php to gray out out-of-stock product variations:
    add_filter( ‘woocommerce_variation_is_active’, ‘grey_out_variations_when_out_of_stock’, 10, 2 );

    function grey_out_variations_when_out_of_stock( $grey_out, $variation ) {

    if ( ! $variation->is_in_stock() )
    return false;

    return true;
    }

    It worked when I unchecked the “Hide out of stock items from catalog” option in Woocommerce>>>Inventory.
    Please teach me how to hide out of stock products instead of product variations? Thanks.

  • The topic ‘How to hide out of stock products instead of product variations?’ is closed to new replies.