Created
July 8, 2021 17:25
-
-
Save jorpdesigns/6fcbd763e65f347d20dcd6840350da93 to your computer and use it in GitHub Desktop.
Snippet to disable out of stock WooCommerce product variations
This file contains hidden or 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
| <?php | |
| add_filter( 'woocommerce_variation_is_active', 'disable_out_of_stock_variations', 10, 2 ); | |
| function disable_out_of_stock_variations( $active, $variation ) { | |
| if( ! $variation->is_in_stock() ) { | |
| return false; | |
| } | |
| return $active; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment