Created
October 8, 2020 13:49
-
-
Save Preciousomonze/288683ee42ed4424854b7a8d02afe02a to your computer and use it in GitHub Desktop.
Alter WooCommerce Product Catalog visibility via hook. Based on this thread here: https://woocommercecommunity.slack.com/archives/C1KAZ91E3/p1601981478254000
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 | |
/** | |
* Change catalog visibility. | |
* | |
* No need to run ::save(), cause this hook is run before $product->save() | |
* | |
* Hooked to woocommerce_admin_process_product_object | |
* | |
* @param WC_Product $product The product object. | |
*/ | |
function pekky_save_product_data( $product ) { | |
$product->set_catalog_visibility( 'hidden' ); | |
} | |
add_filter( 'woocommerce_admin_process_product_object', 'pekky_save_product_data' ); |
Glad it worked! π
Don't forget to have a nice day and try out pancakes πͺπΌπ₯
Over and out! ππ½ββοΈ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
got it working thanks to this, thank you! (couldn't edit visibility on product status change any other way, changes to visibility never got persisted)
im using it like this: