[PHP] Set instock for all WooCommerce products without edit manual

Maybe you got problem with stock when feed your product to your website or to platform for ads.
This snippet PHP will help you set all products instock without edit them.

Put snippet below in to your functions.php file the make it works

add_filter( 'woocommerce_product_get_stock_status', 'sg_product_get_stock_status', 99, 2 );
add_filter( 'woocommerce_product_variation_get_stock_status', 'sg_product_get_stock_status', 99, 2 );
function sg_product_get_stock_status( $value='', $obj ) {
	return 'instock';
}
add_filter('woocommerce_product_is_in_stock', 'sg_woocommerce_product_is_in_stock' );
function sg_woocommerce_product_is_in_stock( ) {
	return true;
}
Zalo
Telegram
Messenger
Messenger
Telegram
Zalo