Created
September 26, 2024 09:12
-
-
Save shameemreza/332754e1e596531f37db031319fbe163 to your computer and use it in GitHub Desktop.
Hide out of stock variations from variable product page in WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_variation_is_visible', 'hide_out_of_stock_variations', 10, 4 ); | |
function hide_out_of_stock_variations( $is_visible, $variation_id, $product_id, $variation ) { | |
if ( ! $variation->is_in_stock() ) { | |
$is_visible = false; | |
} | |
return $is_visible; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment