Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created March 15, 2018 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save plugin-republic/7429a72127e527ad1c68821773001863 to your computer and use it in GitHub Desktop.
Save plugin-republic/7429a72127e527ad1c68821773001863 to your computer and use it in GitHub Desktop.
/**
* 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