Forked from plugin-republic/woocommerce_variation_is_active.php
Created
February 1, 2021 05:55
-
-
Save blogjunkie/9493f5831bbb6c630d73537e47080365 to your computer and use it in GitHub Desktop.
Grey out variations that are out of stock for 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
/** | |
* Disable out of stock variations | |
* https://github.com/woocommerce/woocommerce/blob/826af31e1e3b6e8e5fc3c1004cc517c5c5ec25b1/includes/class-wc-product-variation.php | |
* @return Boolean | |
*/ | |
function wcbv_variation_is_active( $active, $variation ) { | |
if( ! $variation->is_in_stock() ) { | |
return false; | |
} | |
return $active; | |
} | |
add_filter( 'woocommerce_variation_is_active', 'wcbv_variation_is_active', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more control over display of out of stock variations, see:
https://pluginrepublic.com/wordpress-plugins/woocommerce-better-variations/