Created
April 28, 2020 09:48
-
-
Save codeagencybe/f2ad4211ed25ffc60247722170b40081 to your computer and use it in GitHub Desktop.
WooCommerce Display out of stock variable products as unavailable
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
| /** | |
| * Disable out of stock variations | |
| * https://github.com/woocommerce/woocommerce/blob/826af31e1e3b6e8e5fc3c1004cc517c5c5ec25b1/includes/class-wc-product-variation.php | |
| * @return Boolean | |
| * Description: unset WooCommerce billing & shipping address_1 field in checkout in favor for 2 new custom fields street and houseno | |
| * Author: Code Agency | |
| * Author URI: https://codeagency.be | |
| */ | |
| function codeagency_variation_is_active( $active, $variation ) { | |
| if( ! $variation->is_in_stock() ) { | |
| return false; | |
| } | |
| return $active; | |
| } | |
| add_filter( 'woocommerce_variation_is_active', 'codeagency_variation_is_active', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment